mirror of
https://github.com/nmap/nmap.git
synced 2026-11-20 08:40:36 +08:00
Fuzzers for a couple libnetutil functions
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
fuzz_PacketParser
|
||||
fuzz_dns_packet_parseFromBuffer
|
||||
fuzz_ippackethdrinfo
|
||||
fuzz_traceroute_decode_reply
|
||||
corpus/
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "common.h"
|
||||
#include "../libnetutil/PacketParser.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C"
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
fuzz_init();
|
||||
|
||||
PacketParser pp;
|
||||
PacketElement *pe = NULL;
|
||||
pe = pp.split(data, size);
|
||||
|
||||
pp.test_packet_parser(pe);
|
||||
pp.freePacketChain(pe);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "common.h"
|
||||
#include "../libnetutil/netutil.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C"
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
fuzz_init();
|
||||
|
||||
const int levels[] = {
|
||||
LOW_DETAIL,
|
||||
MEDIUM_DETAIL,
|
||||
HIGH_DETAIL
|
||||
};
|
||||
const char *buf = NULL;
|
||||
static volatile size_t len = 0;
|
||||
for (int i = 0; i < sizeof(levels)/sizeof(levels[0]); i++) {
|
||||
buf = ippackethdrinfo(data, size, levels[i]);
|
||||
len = strlen(buf);
|
||||
if (strncmp(buf, "BOGUS", 5) == 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user