| 5 | #include <iostream> |
| 6 | |
| 7 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 8 | // Invalid files generate a lot of warnings, so switch off logging. |
| 9 | Exiv2::LogMsg::setLevel(Exiv2::LogMsg::mute); |
| 10 | |
| 11 | Exiv2::XmpParser::initialize(); |
| 12 | ::atexit(Exiv2::XmpParser::terminate); |
| 13 | |
| 14 | try { |
| 15 | Exiv2::DataBuf data_copy(data, size); |
| 16 | Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(data_copy.c_data(), size); |
| 17 | assert(image.get() != 0); |
| 18 | |
| 19 | image->readMetadata(); |
| 20 | for (auto& md : image->exifData()) { |
| 21 | md.print(&image->exifData()); |
| 22 | } |
| 23 | for (auto& md : image->iptcData()) { |
| 24 | md.print(&image->exifData()); |
| 25 | } |
| 26 | for (auto& md : image->xmpData()) { |
| 27 | md.print(&image->exifData()); |
| 28 | } |
| 29 | |
| 30 | // Print to a std::ostringstream so that the fuzzer doesn't |
| 31 | // produce lots of garbage on stdout. |
| 32 | std::ostringstream buffer; |
| 33 | image->printStructure(buffer, Exiv2::kpsNone); |
| 34 | image->printStructure(buffer, Exiv2::kpsBasic); |
| 35 | image->printStructure(buffer, Exiv2::kpsXMP); |
| 36 | image->printStructure(buffer, Exiv2::kpsRecursive); |
| 37 | image->printStructure(buffer, Exiv2::kpsIccProfile); |
| 38 | image->printStructure(buffer, Exiv2::kpsIptcErase); |
| 39 | |
| 40 | image->writeMetadata(); |
| 41 | |
| 42 | } catch (...) { |
| 43 | // Exiv2 throws an exception if the metadata is invalid. |
| 44 | } |
| 45 | |
| 46 | return 0; |
| 47 | } |
nothing calls this directly
no test coverage detected