shithub: fuzz

Download patch

ref: 450caa3adbf3369cb82aec4add3ffa2acb9cca65
parent: 6a7f8345faf9e90091a06b2263e2729c13835b64
author: seh <seh@localhost>
date: Sat Nov 10 11:44:49 EST 2018

add initialisation for input List and other refactors

--- a/fuzz.h
+++ b/fuzz.h
@@ -99,7 +99,7 @@
 	char*		name;		// Real name of syscall
 	int			round;		// Last run executed
 	int			seed;		// Seed call was initialized with
-//	List		inputs;		// List of input types in order from left→right
+	List		inputs;		// List of input types in order from left→right
 };
 
 // Index of system calls -- one for each enum'd system call
@@ -110,5 +110,12 @@
 // input.c
 void	fuzz(caller*);
 void	hjsync(void);
+
+// inlist.c
+List*	mkinlist(List*, call);
+
+// list.c → See list.h
+
+// mutate.c → See mutate.h
 
 #endif
--- /dev/null
+++ b/inlist.c
@@ -1,0 +1,148 @@
+#include "fuzz.h"
+
+// HERE BE DRAGONS -- this should be moved to a generator
+// Generate the input list for the given syscall
+List*
+mkinlist(List* l, call c)
+{
+	switch(c){
+	case sc_exits	:
+	
+	case sc_abort	:
+	 
+	case sc_access	:
+	 
+	case sc_alarm	:
+	 
+	case sc_await	:
+	 
+	case sc_bind	:
+	 
+	case sc_brk	:
+	 
+	case sc_chdir	:
+	 
+	case sc_close	:
+	 
+	case sc_create	:
+	 
+	case sc_dup	:
+	 
+	case sc_errstr	:
+	 
+	case sc_exec	:
+	 
+	case sc_execl	:
+	 
+	case sc_fork	:
+	 
+	case sc_rfork	:
+	 
+	case sc_fauth	:
+	 
+	case sc_fstat	:
+	 
+	case sc_fwstat	:
+	 
+	case sc_fversion:
+	 
+	case sc_mount	:
+	 
+	case sc_unmount:
+	 
+	case sc_noted	:
+	 
+	case sc_notify	:
+	 
+	case sc_open	:
+	 
+	case sc_fd2path:
+	 
+	case sc_pipe	:
+	 
+	case sc_pread	:
+	 
+	case sc_preadv:
+	 
+	case sc_pwrite	:
+	 
+	case sc_pwritev:
+	 
+	case sc_read	:
+	 
+	case sc_readn	:
+	 
+	case sc_readv	:
+	 
+	case sc_remove:
+	 
+	case sc_sbrk	:
+	 
+	case sc_oseek	:
+	 
+	case sc_seek:
+	 
+	case sc_segattach:
+	 
+	case sc_segbrk	:
+	 
+	case sc_segdetach:
+	 
+	case sc_segflush:
+	 
+	case sc_segfree:
+	 
+	case sc_semacquire:
+	 
+	case sc_semrelease:
+	 
+	case sc_sleep:
+	 
+	case sc_stat:
+	 
+	case sc_tsemacquire:
+	 
+	case sc_wait:
+	 
+	case sc_waitpid:
+	 
+	case sc_write:
+	 
+	case sc_writev:
+	 
+	case sc_wstat:
+	 
+	case sc_rendezvous:
+	 
+	case sc_dirstat:
+	 
+	case sc_dirfstat:
+	 
+	case sc_dirwstat:
+	 
+	case sc_dirfwstat:
+	 
+	case sc_dirread:
+	 
+	case sc_nulldir:
+	 
+	case sc_dirreadall:
+	 
+	case sc_getpid	:
+	 
+	case sc_getppid:
+	 
+	case sc_rerrstr:
+	 
+	case sc_sysname:
+	 
+	case sc_werrstr:
+	 
+	default:
+		return nil;
+	}
+
+
+
+	return l;
+}
--- a/main.c
+++ b/main.c
@@ -1,5 +1,9 @@
 #include "fuzz.h"
 
+// Global variables are bad
+int logfd = -1; // fd of the log file, initialized in main
+
+
 // Commandline usage warning
 void
 usage(void)
@@ -28,6 +32,8 @@
 		default:
 			usage();
 	}ARGEND
+	
+	logfd = open("./fuzz.log", OWRITE);
 
 	// Initialize the table of all system calls
 	initsctable();
@@ -53,6 +59,7 @@
 		}
 	}
 
+	close(logfd);
 	exits(nil);
 }
 
@@ -67,6 +74,7 @@
 		syscalls[i].name = callnames[i]; // Pointer points to callnames
 		syscalls[i].round = -1;
 		syscalls[i].seed = -1;
+		mkinlist(&(syscalls[i].inputs), (call)i);
 	}
 }
 
--- a/mkfile
+++ b/mkfile
@@ -7,9 +7,10 @@
 OFILES = main.$O \
 		input.$O \
 		mutate.$O \
-		list.$O 
+		list.$O \
+		inlist.$O
 
-HFILES = fuzz.h list.h
+HFILES = fuzz.h list.h mutate.h
 
 MAN = fuzz.man