shithub: fuzz

Download patch

ref: 6d59799c93104d3d5148ab19dd08fe4f564d4140
parent: 752a1197a29d380c6ca482f540f00c54b65a7460
author: seh <seh@localhost>
date: Mon Dec 31 16:35:41 EST 2018

use genrandom

--- a/mutate.c
+++ b/mutate.c
@@ -1,4 +1,5 @@
 #include "fuzz.h"
+#include <libsec.h>
 
 // This is the round where if pointers are nil we must then allocate and permutate further from
 #define MALLOC_ROUND 1
@@ -48,6 +49,7 @@
     }
 }
 
+// Create a mutated char*
 char*
 mut_charstar()
 {
@@ -59,61 +61,13 @@
 	    val[i] = rng() % 255;
 	}    
 	return val;
-/*
-    // if not round 1, free the previously malloc-ed memory
-    if(in_val != nil)//*round != MALLOC_ROUND && *round != 0)
-    {
-    //    free(*in_val);
-	debug("mut_charstar: in_val != nil\n");
-    }
-    if (*round == 1)
-    {
-        in_val = malloc(1 * sizeof(char*));
-    }
 
-    if(*round > 0){
-	    const int MAX_SIZE = 256;
-	    int size = rng() % MAX_SIZE + 1;
-
-	    debug("inside mut, round: %d in_val: %p\n", *round, in_val);
-
-	    *in_val = malloc(sizeof(char) * size);
-	    // in_val = malloc(size * sizeof(char));
-
-	    int i;
-	    for(i = 0; i < size; i++)
-	    {
-		(*in_val)[i] = rng() % 255;
-	    }
-	    (*in_val)[size - 1] = '\0';
-    debug("mut_charstar: *in_val : %s\n", *in_val);
-    debug("mut_charstar: in_val : %p\n", in_val);
-	
-    }
-*/
-/*	if (*round == 1)
-	{
-		char** c = malloc(1 * sizeof(char*));
-		in_val = c;
-	}
-	if (*round > 0)
-	{
-		const int MAX_SIZE = 256;
-	    	int size = rng() % MAX_SIZE + 1;
-
-	    	debug("inside mut, round: %d in_val: %p\n", *round, in_val);
-
-		char** c = (char**) in_val;
-		*c = malloc(size * sizeof(char));
-		debug("inside mut, round %d c: %p in_val: %p\n", *round, c, in_val);
-		int i;
-		for(i = 0; i < size; i++)
-		{
-			(*c)[i] = rng() % 255;
-		}
-		(*c)[size - 1] = '\0';
-
-	}*/
+	/*
+	int size = (rng() % (64 + 1 - 2) + 2);
+	char* val = calloc(size, sizeof(char));
+	genrandom(val, size);
+	return val;
+	*/
 }
 
 unsigned char*
@@ -120,7 +74,11 @@
 mut_ucharstar()
 {
 	int size = (rng() % (64 + 1 - 2) + 2);
-	unsigned char* val = calloc(size, sizeof(char));
+	uchar *val = calloc(size, sizeof(uchar));
+	genrandom(val, size * sizeof(uchar));
+	return val;
+	
+	/*
 	int i;
 	for(i = 0; i < size - 1; i++)
 	{
@@ -127,6 +85,7 @@
 	    val[i] = rng() % 255;
 	}    
 	return val;
+	*/
 }
 
 int