Coverage Report

Created: 2026-02-26 06:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/exiv2/fuzz/fuzz-read-write.cpp
Line
Count
Source
1
#include <exiv2/exiv2.hpp>
2
3
#include <cassert>
4
#include <iomanip>
5
#include <iostream>
6
7
23.8k
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
8
  // Invalid files generate a lot of warnings, so switch off logging.
9
23.8k
  Exiv2::LogMsg::setLevel(Exiv2::LogMsg::mute);
10
11
23.8k
  try {
12
23.8k
    Exiv2::DataBuf data_copy(data, size);
13
23.8k
    Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(data_copy.c_data(), size);
14
23.8k
    assert(image.get() != 0);
15
16
23.8k
    image->readMetadata();
17
23.8k
    image->writeMetadata();
18
19
23.8k
  } catch (...) {
20
    // Exiv2 throws an exception if the metadata is invalid.
21
12.3k
  }
22
23
23.8k
  return 0;
24
23.8k
}