Skip to content

Commit

Permalink
other
Browse files Browse the repository at this point in the history
  • Loading branch information
tigercosmos committed Jun 26, 2024
1 parent 52a3cb0 commit a32c83d
Show file tree
Hide file tree
Showing 53 changed files with 3,883 additions and 3,665 deletions.
4 changes: 2 additions & 2 deletions Tests/Fuzzers/DumpToFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

// This function is created as PcapPlusPlus doesn't seem to offer a way of
// parsing Pcap files directly from memory
static int dumpDataToPcapFile(const uint8_t *data, size_t size, const char* path)
static int dumpDataToPcapFile(const uint8_t* data, size_t size, const char* path)
{
FILE *fd;
FILE* fd;
int written = 0;

fd = fopen(path, "wb");
Expand Down
13 changes: 6 additions & 7 deletions Tests/Fuzzers/FuzzTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
static std::string tmpName;
static std::string tmpFile;

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
if (tmpName.empty())
tmpName = tmpnam (NULL);
tmpName = tmpnam(NULL);

if (tmpFile.empty())
tmpFile = tmpName + FILE_EXT;
Expand All @@ -32,15 +32,14 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)

pcpp::IPcapDevice::PcapStats stats;
reader->getStatistics(stats);
std::cout << "Read " << stats.packetsRecv << " packets successfully and "
<< stats.packetsDrop << " packets could not be read" << std::endl;
std::cout << "Read " << stats.packetsRecv << " packets successfully and " << stats.packetsDrop
<< " packets could not be read" << std::endl;

if (auto ngReader = dynamic_cast<pcpp::PcapNgFileReaderDevice*>(reader.get()))
{
std::cout << "OS is '" << ngReader->getOS() << "'; Hardware is '" << ngReader->getHardware() << "'"
<< "'; CaptureApplication is '" << ngReader->getCaptureApplication()
<< "'; CaptureFileComment is '" << ngReader->getCaptureFileComment()
<< "'" << std::endl;
<< "'; CaptureApplication is '" << ngReader->getCaptureApplication() << "'; CaptureFileComment is '"
<< ngReader->getCaptureFileComment() << "'" << std::endl;
}

pcpp::RawPacketVector packets;
Expand Down
12 changes: 6 additions & 6 deletions Tests/Fuzzers/FuzzWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ static std::string tmpFile;
static std::string outPcapFile;
static int writes = 0;

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
if (tmpName.empty())
tmpName = tmpnam (NULL);
tmpName = tmpnam(NULL);

if (tmpFile.empty())
tmpFile = tmpName + FILE_EXT;
Expand Down Expand Up @@ -41,9 +41,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
#endif

#ifdef NG_WRITER
pcpp::PcapNgFileWriterDevice pcapWriter(outPcapFile);
pcpp::PcapNgFileWriterDevice pcapWriter(outPcapFile);
#else
pcpp::PcapFileWriterDevice pcapWriter(outPcapFile, pcpp::LINKTYPE_ETHERNET);
pcpp::PcapFileWriterDevice pcapWriter(outPcapFile, pcpp::LINKTYPE_ETHERNET);
#endif
if (writes++ == 10)
{
Expand Down Expand Up @@ -71,8 +71,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)

pcpp::IPcapDevice::PcapStats stats;
pcapWriter.getStatistics(stats);
std::cout << "Written " << stats.packetsRecv << " packets successfully to pcap writer and "
<< stats.packetsDrop << " packets could not be written" << std::endl;
std::cout << "Written " << stats.packetsRecv << " packets successfully to pcap writer and " << stats.packetsDrop
<< " packets could not be written" << std::endl;

pcapWriter.close();
return 0;
Expand Down
Loading

0 comments on commit a32c83d

Please sign in to comment.