MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / LLVMFuzzerTestOneInput

Function LLVMFuzzerTestOneInput

fuzz/fuzz-preview.cpp:7–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include <iostream>
6
7extern "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
21 Exiv2::PreviewManager pm(*image);
22 std::ostringstream os;
23 Exiv2::PreviewPropertiesList list = pm.getPreviewProperties();
24 for (const auto& pos : list) {
25 os << pos.mimeType_ << "\n";
26
27 if (pos.width_ != 0 && pos.height_ != 0)
28 os << pos.width_ << " " << pos.height_ << " ";
29
30 os << pos.size_ << "\n";
31 }
32
33 } catch (...) {
34 // Exiv2 throws an exception if the metadata is invalid.
35 }
36
37 return 0;
38}

Callers

nothing calls this directly

Calls 4

c_dataMethod · 0.80
getMethod · 0.80
getPreviewPropertiesMethod · 0.80
readMetadataMethod · 0.45

Tested by

no test coverage detected