changeset 1775:8179eabe16c9

fuzzing - fix some wrong types and -lcrypt on macos
author Matt Johnston <matt@ucc.asn.au>
date Mon, 02 Nov 2020 20:33:48 +0800
parents 833bf9947603
children 290caf301a4f
files Makefile.in fuzz/fuzz-common.c fuzz/fuzz-harness.c fuzz/fuzz-sshpacketmutator.c
diffstat 4 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.in	Sun Nov 01 23:44:58 2020 +0800
+++ b/Makefile.in	Mon Nov 02 20:33:48 2020 +0800
@@ -290,7 +290,7 @@
 fuzz-targets: $(FUZZ_TARGETS) $(FUZZER_OPTIONS)
 
 $(FUZZ_TARGETS): $(FUZZ_OBJS) $(allobjs) $(LIBTOM_DEPS) 
-	$(CXX) $(CXXFLAGS) fuzz/[email protected] $(LDFLAGS) $(allobjs) -o $@$(EXEEXT) $(LIBTOM_LIBS) $(LIBS) $(FUZZLIB) -lcrypt
+	$(CXX) $(CXXFLAGS) fuzz/[email protected] $(LDFLAGS) $(allobjs) -o $@$(EXEEXT) $(LIBTOM_LIBS) $(LIBS) $(FUZZLIB) @CRYPTLIB@
 
 # fuzzers that use the custom mutator - these expect a SSH network stream
 MUTATOR_FUZZERS=fuzzer-client fuzzer-client_nomaths \
--- a/fuzz/fuzz-common.c	Sun Nov 01 23:44:58 2020 +0800
+++ b/fuzz/fuzz-common.c	Mon Nov 02 20:33:48 2020 +0800
@@ -239,7 +239,7 @@
     }
 
     uint32_t wrapseed;
-    genrandom(&wrapseed, sizeof(wrapseed));
+    genrandom((void*)&wrapseed, sizeof(wrapseed));
     wrapfd_setseed(wrapseed);
 
     int fakesock = wrapfd_new();
@@ -275,7 +275,7 @@
     ses.kexstate.donefirstkex = 1;
 
     uint32_t wrapseed;
-    genrandom(&wrapseed, sizeof(wrapseed));
+    genrandom((void*)&wrapseed, sizeof(wrapseed));
     wrapfd_setseed(wrapseed);
 
     int fakesock = wrapfd_new();
--- a/fuzz/fuzz-harness.c	Sun Nov 01 23:44:58 2020 +0800
+++ b/fuzz/fuzz-harness.c	Mon Nov 02 20:33:48 2020 +0800
@@ -47,7 +47,8 @@
     return 0;
 }
 
-size_t LLVMFuzzerMutate(uint8_t *Data, size_t Size, size_t MaxSize) {
+// Just to let it link
+size_t LLVMFuzzerMutate(uint8_t *UNUSED(Data), size_t UNUSED(Size), size_t UNUSED(MaxSize)) {
     printf("standalone fuzzer harness shouldn't call LLVMFuzzerMutate");
     abort();
     return 0;
--- a/fuzz/fuzz-sshpacketmutator.c	Sun Nov 01 23:44:58 2020 +0800
+++ b/fuzz/fuzz-sshpacketmutator.c	Mon Nov 02 20:33:48 2020 +0800
@@ -285,7 +285,7 @@
         unsigned int num_out = min_out + nrand48(randstate) % (max_out-min_out+1);
 
         for (i = 0; i < num_out; i++) {
-            int choose = nrand48(randstate) % (num_packets1 + num_packets2);
+            unsigned int choose = nrand48(randstate) % (num_packets1 + num_packets2);
             buffer *p = NULL;
             if (choose < num_packets1) {
                 p = packets1[choose];