Coverage Report

Created: 2026-02-26 06:40

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
938
{
9
938
  FILE* fd;
10
938
  int written = 0;
11
12
938
  fd = fopen(path, "wb");
13
938
  if (fd == nullptr)
14
0
  {
15
0
    std::cerr << "Error opening pcap file for writing\n";
16
0
    return -1;
17
0
  }
18
19
938
  written = fwrite(data, 1, size, fd);
20
938
  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
938
  fclose(fd);
28
938
  return 0;
29
938
}