@@ -138,19 +138,6 @@ namespace {
138138// *****************************************************************************
139139// class member definitions
140140namespace Exiv2 {
141- // BasicIo::read() with error checking
142- static void readOrThrow (BasicIo& iIo, byte* buf, long rcount, ErrorCode err) {
143- const long nread = iIo.read (buf, rcount);
144- enforce (nread == rcount, err);
145- enforce (!iIo.error (), err);
146- }
147-
148- // BasicIo::seek() with error checking
149- static void seekOrThrow (BasicIo& iIo, long offset, BasicIo::Position pos, ErrorCode err) {
150- const int r = iIo.seek (offset, pos);
151- enforce (r == 0 , err);
152- }
153-
154141 Image::Image (int imageType, uint16_t supportedMetadata, BasicIo::UniquePtr io)
155142 : io_(std::move(io)),
156143 pixelWidth_ (0 ),
@@ -342,8 +329,8 @@ namespace Exiv2 {
342329
343330 do {
344331 // Read top of directory
345- seekOrThrow (io, start, BasicIo::beg, kerCorruptedMetadata);
346- readOrThrow (io, dir.data (), 2 , kerCorruptedMetadata);
332+ io. seekOrThrow (start, BasicIo::beg, kerCorruptedMetadata);
333+ io. readOrThrow (dir.data (), 2 , kerCorruptedMetadata);
347334 uint16_t dirLength = byteSwap2 (dir,0 ,bSwap);
348335 // Prevent infinite loops. (GHSA-m479-7frc-gqqg)
349336 enforce (dirLength > 0 , kerCorruptedMetadata);
@@ -369,7 +356,7 @@ namespace Exiv2 {
369356 }
370357 bFirst = false ;
371358
372- readOrThrow (io, dir.data (), 12 , kerCorruptedMetadata);
359+ io. readOrThrow (dir.data (), 12 , kerCorruptedMetadata);
373360 uint16_t tag = byteSwap2 (dir,0 ,bSwap);
374361 uint16_t type = byteSwap2 (dir,2 ,bSwap);
375362 uint32_t count = byteSwap4 (dir,4 ,bSwap);
@@ -420,9 +407,9 @@ namespace Exiv2 {
420407
421408 if ( bOffsetIsPointer ) { // read into buffer
422409 const long restore = io.tell (); // save
423- seekOrThrow (io, offset, BasicIo::beg, kerCorruptedMetadata); // position
424- readOrThrow (io, buf.data (), static_cast <long >(count_x_size), kerCorruptedMetadata); // read
425- seekOrThrow (io, restore, BasicIo::beg, kerCorruptedMetadata); // restore
410+ io. seekOrThrow (offset, BasicIo::beg, kerCorruptedMetadata); // position
411+ io. readOrThrow (buf.data (), static_cast <long >(count_x_size), kerCorruptedMetadata); // read
412+ io. seekOrThrow (restore, BasicIo::beg, kerCorruptedMetadata); // restore
426413 }
427414
428415 if ( bPrint ) {
@@ -464,7 +451,7 @@ namespace Exiv2 {
464451 const long restore = io.tell ();
465452 offset = byteSwap4 (buf,k*size,bSwap);
466453 printIFDStructure (io,out,option,offset,bSwap,c,depth);
467- seekOrThrow (io, restore, BasicIo::beg, kerCorruptedMetadata);
454+ io. seekOrThrow (restore, BasicIo::beg, kerCorruptedMetadata);
468455 }
469456 } else if ( option == kpsRecursive && tag == 0x83bb /* IPTCNAA */ ) {
470457 if (count > 0 ) {
@@ -473,11 +460,11 @@ namespace Exiv2 {
473460 }
474461
475462 const long restore = io.tell ();
476- seekOrThrow (io, offset, BasicIo::beg, kerCorruptedMetadata); // position
463+ io. seekOrThrow (offset, BasicIo::beg, kerCorruptedMetadata); // position
477464 std::vector<byte> bytes (count) ; // allocate memory
478465 // TODO: once we have C++11 use bytes.data()
479- readOrThrow (io, &bytes[0 ], count, kerCorruptedMetadata);
480- seekOrThrow (io, restore, BasicIo::beg, kerCorruptedMetadata);
466+ io. readOrThrow (&bytes[0 ], count, kerCorruptedMetadata);
467+ io. seekOrThrow (restore, BasicIo::beg, kerCorruptedMetadata);
481468 // TODO: once we have C++11 use bytes.data()
482469 IptcData::printStructure (out, makeSliceUntil (&bytes[0 ], count), depth);
483470 }
@@ -487,8 +474,8 @@ namespace Exiv2 {
487474 uint32_t jump= 10 ;
488475 byte bytes[20 ] ;
489476 const auto chars = reinterpret_cast <const char *>(&bytes[0 ]);
490- seekOrThrow (io, offset, BasicIo::beg, kerCorruptedMetadata); // position
491- readOrThrow (io, bytes, jump, kerCorruptedMetadata) ; // read
477+ io. seekOrThrow (offset, BasicIo::beg, kerCorruptedMetadata); // position
478+ io. readOrThrow (bytes, jump, kerCorruptedMetadata) ; // read
492479 bytes[jump]=0 ;
493480
494481 bool bNikon = ::strcmp (" Nikon" ,chars) == 0 ;
@@ -498,17 +485,17 @@ namespace Exiv2 {
498485 // tag is an embedded tiff
499486 const long byteslen = count-jump;
500487 DataBuf bytes (byteslen); // allocate a buffer
501- readOrThrow (io, bytes.data (), byteslen, kerCorruptedMetadata); // read
488+ io. readOrThrow (bytes.data (), byteslen, kerCorruptedMetadata); // read
502489 MemIo memIo (bytes.c_data (), byteslen) ; // create a file
503490 printTiffStructure (memIo,out,option,depth);
504491 } else {
505492 // tag is an IFD
506493 uint32_t punt = bSony ? 12 : 0 ;
507- seekOrThrow (io, 0 , BasicIo::beg, kerCorruptedMetadata); // position
494+ io. seekOrThrow (0 , BasicIo::beg, kerCorruptedMetadata); // position
508495 printIFDStructure (io,out,option,offset+punt,bSwap,c,depth);
509496 }
510497
511- seekOrThrow (io, restore, BasicIo::beg, kerCorruptedMetadata); // restore
498+ io. seekOrThrow (restore, BasicIo::beg, kerCorruptedMetadata); // restore
512499 }
513500 }
514501
@@ -521,7 +508,7 @@ namespace Exiv2 {
521508 }
522509 }
523510 if ( start ) {
524- readOrThrow (io, dir.data (), 4 , kerCorruptedMetadata);
511+ io. readOrThrow (dir.data (), 4 , kerCorruptedMetadata);
525512 start = byteSwap4 (dir,0 ,bSwap);
526513 }
527514 } while (start) ;
@@ -541,7 +528,7 @@ namespace Exiv2 {
541528 DataBuf dir (dirSize);
542529
543530 // read header (we already know for certain that we have a Tiff file)
544- readOrThrow (io, dir.data (), 8 , kerCorruptedMetadata);
531+ io. readOrThrow (dir.data (), 8 , kerCorruptedMetadata);
545532 char c = static_cast <char >(dir.read_uint8 (0 ));
546533 bool bSwap = ( c == ' M' && isLittleEndianPlatform () )
547534 || ( c == ' I' && isBigEndianPlatform () )
0 commit comments