mirror of
https://github.com/nmap/nmap.git
synced 2026-10-22 11:51:52 +00:00
Fuzzer for various hex-related utility functions
This commit is contained in:
parent
23d13f12f7
commit
3ca969ce85
2 changed files with 33 additions and 0 deletions
2
fuzz/.gitignore
vendored
2
fuzz/.gitignore
vendored
|
|
@ -3,4 +3,6 @@ fuzz_dns_packet_parseFromBuffer
|
|||
fuzz_ippackethdrinfo
|
||||
fuzz_traceroute_decode_reply
|
||||
fuzz_gettcpopt_ts
|
||||
fuzz_validatepkt
|
||||
fuzz_hexutils
|
||||
corpus/
|
||||
|
|
|
|||
31
fuzz/fuzz_hexutils.cc
Normal file
31
fuzz/fuzz_hexutils.cc
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "common.h"
|
||||
#include "../output.h"
|
||||
#include "../utils.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C"
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
fuzz_init();
|
||||
unsigned int newlen = 0;
|
||||
char *cbuf = new char[size + 1];
|
||||
memcpy(cbuf, data, size);
|
||||
cbuf[size] = '\0';
|
||||
char *cdata = cstring_unescape(cbuf, &newlen);
|
||||
int bufsize = newlen * 4 + newlen / 8 + 1;
|
||||
char *buf = new char[bufsize];
|
||||
|
||||
bintohexstr(buf, bufsize, cdata, (int)newlen);
|
||||
size_t phs_len = 0;
|
||||
u8 *phs_buf = parse_hex_string(buf, &phs_len);
|
||||
if (phs_buf != NULL) {
|
||||
volatile std::string safe = protect_xml(std::string((char *)phs_buf, phs_len));
|
||||
(void) safe;
|
||||
}
|
||||
|
||||
delete[] buf;
|
||||
delete[] cbuf;
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue