mirror of
https://github.com/samba-team/samba.git
synced 2025-01-08 21:18:16 +03:00
lib/fuzzing: LLVMFuzzerTestOneInput() takes const uint8_t*
We have been using `uint8_t *`, which works fine as far as linking goes, but leads fuzz target developers to sometimes forget why they can't just modify the passed in string instead of copying it for modification (e.g. to NUL-terminate). REF: https://llvm.org/docs/LibFuzzer.html#fuzz-target Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
43b44827d6
commit
5c81f34935
@ -25,7 +25,7 @@ char buf[MAX_LENGTH + 1];
|
||||
const enum credentials_obtained obtained = CRED_UNINITIALISED;
|
||||
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *input, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *input, size_t len)
|
||||
{
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
struct cli_credentials *credentials = NULL;
|
||||
|
@ -24,7 +24,7 @@
|
||||
char buf[MAX_LENGTH + 1];
|
||||
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *input, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *input, size_t len)
|
||||
{
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
struct dcerpc_binding *binding = NULL;
|
||||
|
@ -27,7 +27,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
TALLOC_CTX *mem_ctx = talloc_init(__FUNCTION__);
|
||||
struct asn1_data *asn1;
|
||||
|
@ -23,7 +23,7 @@
|
||||
#define MAX_LENGTH (2 * 1024 * 1024 - 1)
|
||||
char buf[MAX_LENGTH + 1] = {0};
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *input, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *input, size_t len)
|
||||
{
|
||||
struct ldb_dn *dn = NULL;
|
||||
struct ldb_context *ldb = ldb_init(NULL, NULL);
|
||||
|
@ -23,7 +23,7 @@
|
||||
#define MAX_LENGTH (2 * 1024 * 1024 - 1)
|
||||
char buf[MAX_LENGTH + 1] = {0};
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *input, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *input, size_t len)
|
||||
{
|
||||
struct ldb_ldif *ldif = NULL;
|
||||
const char *s = NULL;
|
||||
|
@ -34,7 +34,7 @@ static char * possibly_truncate(uint8_t *input, size_t len)
|
||||
}
|
||||
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *input, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *input, size_t len)
|
||||
{
|
||||
TALLOC_CTX *mem_ctx = talloc_init(__FUNCTION__);
|
||||
struct ldb_val val = {0};
|
||||
|
@ -23,7 +23,7 @@
|
||||
#define MAX_LENGTH (2 * 1024 * 1024 - 1)
|
||||
char buf[MAX_LENGTH + 1] = {0};
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *input, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *input, size_t len)
|
||||
{
|
||||
struct ldb_control *control = NULL;
|
||||
struct ldb_context *ldb = ldb_init(NULL, NULL);
|
||||
|
@ -26,7 +26,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
TALLOC_CTX *mem_ctx = talloc_init(__FUNCTION__);
|
||||
struct ldb_parse_tree *tree;
|
||||
|
@ -25,7 +25,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
static uint8_t output[1024 * 1024] = {0};
|
||||
|
||||
|
@ -25,7 +25,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
static uint8_t output[1024 * 1024] = {0};
|
||||
|
||||
|
@ -29,7 +29,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
|
||||
#define MAX_SIZE (1024 * 1024)
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
static uint8_t *output;
|
||||
size_t output_len;
|
||||
|
@ -28,7 +28,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
|
||||
static uint8_t output[1024 * 1024] = {0};
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
size_t target_len;
|
||||
if (len < 4) {
|
||||
|
@ -28,7 +28,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
}
|
||||
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
/*
|
||||
* we allow compressed to be 25% bigger than decompressed.
|
||||
|
@ -25,7 +25,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
static uint8_t compressed[1024 * 1280] = {0};
|
||||
static uint8_t decompressed[1024 * 1024] = {0};
|
||||
|
@ -150,7 +150,7 @@ static void ndr_print_nothing(struct ndr_print *ndr, const char *format, ...)
|
||||
}
|
||||
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
uint8_t type;
|
||||
int pull_push_print_flags;
|
||||
uint16_t fuzz_packet_flags, function;
|
||||
|
@ -26,7 +26,7 @@
|
||||
char buf[MAX_LENGTH + 1];
|
||||
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *input, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *input, size_t len)
|
||||
{
|
||||
struct packet_struct *p = NULL;
|
||||
struct in_addr ip = {
|
||||
|
@ -29,7 +29,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
TALLOC_CTX *mem_ctx;
|
||||
struct conv_options opt;
|
||||
|
@ -28,7 +28,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
#define MAX_LENGTH (1024 * 1024)
|
||||
char line[MAX_LENGTH + 1];
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *input, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *input, size_t len)
|
||||
{
|
||||
enum printing_types printing_type;
|
||||
print_queue_struct pq_buf = {0};
|
||||
|
@ -31,7 +31,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
const reg_parse_callback cb = {0};
|
||||
|
||||
|
@ -36,7 +36,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
REGF_FILE* regfile;
|
||||
REGF_NK_REC *nk, *subkey;
|
||||
|
@ -63,7 +63,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
}
|
||||
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *input, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *input, size_t len)
|
||||
{
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
struct security_descriptor *sd = NULL;
|
||||
|
@ -32,7 +32,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
}
|
||||
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *input, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *input, size_t len)
|
||||
{
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
struct security_descriptor *sd1 = NULL;
|
||||
|
@ -28,7 +28,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
}
|
||||
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *input, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *input, size_t len)
|
||||
{
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
struct security_token_descriptor_fuzzing_pair p = {0};
|
||||
|
@ -46,7 +46,7 @@ CMP_FN(uint64_t)
|
||||
|
||||
#define MAX_SIZE (1024 * 1024)
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
samba_compare_fn_t fn;
|
||||
|
@ -38,7 +38,7 @@ static int cmp_int8(int8_t *a, int8_t *b, int8_t *c)
|
||||
|
||||
#define MAX_SIZE (1024 * 1024)
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
int8_t buf2[MAX_SIZE];
|
||||
|
@ -25,7 +25,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len)
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
struct tiniparser_dictionary *d = NULL;
|
||||
|
@ -25,6 +25,6 @@
|
||||
|
||||
/* Prototypes for fuzzing interface */
|
||||
int LLVMFuzzerInitialize(int *argc, char ***argv);
|
||||
int LLVMFuzzerTestOneInput(uint8_t * buf, size_t len);
|
||||
int LLVMFuzzerTestOneInput(const uint8_t * buf, size_t len);
|
||||
|
||||
#endif /* _SAMBA_FUZZING_H */
|
||||
|
Loading…
Reference in New Issue
Block a user