shithub: fuzz

Download patch

ref: 10d17ce3dffe0f204eb73e069a0eca5b11632612
parent: 2e3f01aecec2284af77579901e01883364210131
author: Steven Sleder <[email protected]>
date: Wed Nov 21 01:04:54 EST 2018

primitive type mutates are complete, need to fix printing issue and do complex types

--- a/main.c
+++ b/main.c
@@ -70,7 +70,12 @@
 		fprint(2, "Error: Failed to create/open log file.");
 		exits("log file create fail");
 	}
-	
+
+	// save so we don't have two different time(0)'s
+	int fuzz_seed = time(0);
+	srand(fuzz_seed);
+	dolog("==Seed Value: %d==\n", fuzz_seed);
+
 	// Operate for the desired number of rounds, -1 is infinite
 	for(i = 0; i < nrounds || nrounds < 0; i++){
 		int j;
--- a/mutate.c
+++ b/mutate.c
@@ -12,15 +12,15 @@
 void
 mut_int(int* in_val)
 {
-	int shifter = rand() % (4 + 1 - 0) + 0;
-	(*in_val) << shifter;
+	(*in_val) << (rand() % (4 + 1 - 0) + 0);
+	(*in_val) |= (rand() % (15 + 1 - 0) + 0);
 }
 
 void
 mut_uint(unsigned int* in_val)
 {
-	int shifter = rand() % (4 + 1 - 0) + 0;
-	(*in_val) << shifter;
+	(*in_val) << (rand() % (4 + 1 - 0) + 0);
+	(*in_val) |= (rand() % (15 + 1 - 0) + 0);
 }
 
 void
@@ -44,8 +44,8 @@
 void
 mut_long(long* in_val)
 {
-	int shifter = rand() % (4 + 1 - 0) + 0;
-	(*in_val) << shifter;
+	(*in_val) << (rand() % (4 + 1 - 0) + 0);
+	(*in_val) |= (rand() % (15 + 1 - 0) + 0);
 }
 
 void
@@ -56,15 +56,15 @@
 void
 mut_ulong(unsigned long* in_val)
 {
-	int shifter = rand() % (4 + 1 - 0) + 0;
-	(*in_val) << shifter;
+	(*in_val) << (rand() % (4 + 1 - 0) + 0);
+	(*in_val) |= (rand() % (15 + 1 - 0) + 0);
 }
 
 void
 mut_vlong(long long* in_val)
 {
-	int shifter = rand() % (4 + 1 - 0) + 0;
-	(*in_val) << shifter;
+	(*in_val) << (rand() % (4 + 1 - 0) + 0);
+	(*in_val) |= (rand() % (15 + 1 - 0) + 0);
 }
 
 void