@@ -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,23 +474,23 @@ 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 if ( ::strcmp (" Nikon" ,chars) == 0 ) {
494481 // tag is an embedded tiff
495482 const long byteslen = count-jump;
496483 DataBuf bytes (byteslen); // allocate a buffer
497- readOrThrow (io, bytes.data (), byteslen, kerCorruptedMetadata); // read
484+ io. readOrThrow (bytes.data (), byteslen, kerCorruptedMetadata); // read
498485 MemIo memIo (bytes.c_data (), byteslen) ; // create a file
499486 printTiffStructure (memIo,out,option,depth);
500487 } else {
501488 // tag is an IFD
502- seekOrThrow (io, 0 , BasicIo::beg, kerCorruptedMetadata); // position
489+ io. seekOrThrow (0 , BasicIo::beg, kerCorruptedMetadata); // position
503490 printIFDStructure (io,out,option,offset,bSwap,c,depth);
504491 }
505492
506- seekOrThrow (io, restore, BasicIo::beg, kerCorruptedMetadata); // restore
493+ io. seekOrThrow (restore, BasicIo::beg, kerCorruptedMetadata); // restore
507494 }
508495 }
509496
@@ -516,7 +503,7 @@ namespace Exiv2 {
516503 }
517504 }
518505 if ( start ) {
519- readOrThrow (io, dir.data (), 4 , kerCorruptedMetadata);
506+ io. readOrThrow (dir.data (), 4 , kerCorruptedMetadata);
520507 start = byteSwap4 (dir,0 ,bSwap);
521508 }
522509 } while (start) ;
@@ -536,7 +523,7 @@ namespace Exiv2 {
536523 DataBuf dir (dirSize);
537524
538525 // read header (we already know for certain that we have a Tiff file)
539- readOrThrow (io, dir.data (), 8 , kerCorruptedMetadata);
526+ io. readOrThrow (dir.data (), 8 , kerCorruptedMetadata);
540527 char c = static_cast <char >(dir.read_uint8 (0 ));
541528 bool bSwap = ( c == ' M' && isLittleEndianPlatform () )
542529 || ( c == ' I' && isBigEndianPlatform () )
0 commit comments