MCPcopy Create free account
hub / github.com/PDAL/PDAL / verify

Method verify

plugins/e57/libE57Format/src/Packet.cpp:323–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321}
322
323void DataPacketHeader::verify( unsigned bufferLength ) const
324{
325 // Verify that packet is correct type
326 // cppcheck-suppress knownConditionTrueFalse; (data is read as a blob, so the const might not
327 // be valid)
328 if ( packetType != DATA_PACKET )
329 {
330 throw E57_EXCEPTION2( ErrorBadCVPacket,
331 "expected Data; packetType=" + toString( packetType ) );
332 }
333
334 // ??? check reserved flags zero?
335
336 // Check packetLength is at least large enough to hold header
337 unsigned packetLength = packetLogicalLengthMinus1 + 1;
338 if ( packetLength < sizeof( *this ) )
339 {
340 throw E57_EXCEPTION2( ErrorBadCVPacket, "DATA; packetLength=" + toString( packetLength ) );
341 }
342
343 // Check packet length is multiple of 4
344 if ( packetLength % 4 )
345 {
346 throw E57_EXCEPTION2( ErrorBadCVPacket, "DATA; packetLength=" + toString( packetLength ) );
347 }
348
349 // Check actual packet length is large enough.
350 if ( bufferLength > 0 && packetLength > bufferLength )
351 {
352 throw E57_EXCEPTION2( ErrorBadCVPacket, "DATA; packetLength=" + toString( packetLength ) +
353 " bufferLength=" + toString( bufferLength ) );
354 }
355
356 // Make sure there is at least one entry in packet
357 if ( hasRecords() && ( bytestreamCount == 0 ) )
358 {
359 throw E57_EXCEPTION2( ErrorBadCVPacket,
360 "DATA; bytestreamCount=" + toString( bytestreamCount ) );
361 }
362
363 // Check packet is at least long enough to hold bytestreamBufferLength array
364 if ( ( sizeof( DataPacketHeader ) + 2 * bytestreamCount ) > packetLength )
365 {
366 throw E57_EXCEPTION2( ErrorBadCVPacket,
367 "DATA; packetLength=" + toString( packetLength ) +
368 " bytestreamCount=" + toString( bytestreamCount ) );
369 }
370}
371
372#ifdef E57_ENABLE_DIAGNOSTIC_OUTPUT
373void DataPacketHeader::dump( int indent, std::ostream &os ) const

Callers 5

closeMethod · 0.45
packetWriteMethod · 0.45
readPacketMethod · 0.45

Calls 1

toStringFunction · 0.70

Tested by

no test coverage detected