Skip to content
Snippets Groups Projects

Add fuzzing testing setup

1 file
+ 8
4
Compare changes
  • Side-by-side
  • Inline
+ 8
4
@@ -22,6 +22,7 @@
@@ -22,6 +22,7 @@
#include <stdint.h>
#include <stdint.h>
#include <stddef.h>
#include <stddef.h>
 
#include <string.h>
#include "fuzz_helpers.h"
#include "fuzz_helpers.h"
#include "fuzz_data_producer.h"
#include "fuzz_data_producer.h"
@@ -73,10 +74,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size)
@@ -73,10 +74,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size)
up_model = NULL;
up_model = NULL;
break;
break;
case 1:
case 1:
up_model = malloc(size);
up_model = FUZZ_malloc(size);
break;
break;
case 2:
case 2:
up_model = (void *)model; /* in-place update */
up_model = FUZZ_malloc(size);
 
if (model && up_model) {
 
memcpy(up_model, model, size);
 
model = up_model; /* in-place update */
 
}
break;
break;
default:
default:
FUZZ_ASSERT(0);
FUZZ_ASSERT(0);
@@ -130,8 +135,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size)
@@ -130,8 +135,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size)
}
}
free(cmp_data);
free(cmp_data);
if (up_model != model)
free(up_model);
free(up_model);
FUZZ_dataProducer_free(producer);
FUZZ_dataProducer_free(producer);
return 0;
return 0;
}
}
Loading