| 470 | /* =========================================== */ |
| 471 | |
| 472 | void WebPImage::readMetadata() { |
| 473 | if (io_->open() != 0) |
| 474 | throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError()); |
| 475 | IoCloser closer(*io_); |
| 476 | // Ensure that this is the correct image type |
| 477 | if (!isWebPType(*io_, true)) { |
| 478 | if (io_->error() || io_->eof()) |
| 479 | throw Error(ErrorCode::kerFailedToReadImageData); |
| 480 | throw Error(ErrorCode::kerNotAJpeg); |
| 481 | } |
| 482 | clearMetadata(); |
| 483 | |
| 484 | byte data[12]; |
| 485 | DataBuf chunkId(5); |
| 486 | chunkId.write_uint8(4, '\0'); |
| 487 | |
| 488 | io_->readOrThrow(data, WEBP_TAG_SIZE * 3, Exiv2::ErrorCode::kerCorruptedMetadata); |
| 489 | |
| 490 | const uint32_t filesize = Safe::add(Exiv2::getULong(data + WEBP_TAG_SIZE, littleEndian), 8U); |
| 491 | Internal::enforce(filesize <= io_->size(), Exiv2::ErrorCode::kerCorruptedMetadata); |
| 492 | |
| 493 | WebPImage::decodeChunks(filesize); |
| 494 | |
| 495 | } // WebPImage::readMetadata |
| 496 | |
| 497 | void WebPImage::decodeChunks(uint32_t filesize) { |
| 498 | DataBuf chunkId(5); |
nothing calls this directly
no test coverage detected