Coverage Report

Created: 2026-09-28 06:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/PcapPlusPlus/Tests/Fuzzers/DumpToFile.h
Line
Count
Source
1
#pragma once
2
3
#include <iostream>
4
5
// This function is created as PcapPlusPlus doesn't seem to offer a way of
6
// parsing Pcap files directly from memory
7
static int dumpDataToPcapFile(const uint8_t* data, size_t size, const char* path)
8
773
{
9
773
  FILE* fd;
10
773
  int written = 0;
11
12
773
  fd = fopen(path, "wb");
13
773
  if (fd == nullptr)
14
0
  {
15
0
    std::cerr << "Error opening pcap file for writing\n";
16
0
    return -1;
17
0
  }
18
19
773
  written = fwrite(data, 1, size, fd);
20
773
  if (static_cast<size_t>(written) != size)
21
0
  {
22
0
    std::cerr << "Error writing pcap file\n";
23
0
    fclose(fd);
24
0
    return -1;
25
0
  }
26
27
773
  fclose(fd);
28
773
  return 0;
29
773
}