Added undefined behavior sanitizer.

Combined common sanitizer flags.
Added fuzzers.
This commit is contained in:
Chad Fraleigh 2023-07-10 18:35:34 -07:00
parent 5022a9c610
commit 5f6bbd3eb9
No known key found for this signature in database
GPG key ID: 2415C39758458A8F
23 changed files with 813 additions and 4 deletions

38
fuzzing/fuzz-LeaseSet2.cc Normal file
View file

@ -0,0 +1,38 @@
#include <stdint.h>
#include <stddef.h>
#include <LeaseSet.h>
#include "fuzzing.h"
bool
fuzzing_testinput(const uint8_t * data, size_t size)
{
uint8_t storeType;
i2p::data::LeaseSet2 * ls;
if(size < 1)
return true;
storeType = data[0];
// Same check as in NetDb::HandleDatabaseStoreMsg()
if(storeType == i2p::data::NETDB_STORE_TYPE_LEASESET)
return true;
data++;
size--;
// Same check as in NetDb::HandleDatabaseStoreMsg()
if(size > i2p::data::MAX_LS_BUFFER_SIZE)
return true;
ls = new i2p::data::LeaseSet2(storeType, data, size, false);
delete ls;
return true;
}