shithub: fuzz

Download patch

ref: 6036b6482925e14a188bde6f1f4cd0320563a428
parent: 3e1ae0620401232b436c4afe2bb4ee75a6880cf3
author: seh <seh@localhost>
date: Tue Nov 6 09:29:13 EST 2018

Rework boilerplate for calls and populate table of syscall names

--- a/fuzz.h
+++ b/fuzz.h
@@ -1,9 +1,12 @@
 #ifndef FUZZ_H
 #define FUZZ_H
+#include <u.h>
+#include <libc.h>
 #include "list.h"
+#include "mutate.h"
 
 // Number of calls in enum calls
-#define NCALLS 65
+#define NCALLS 66
 
 /* 
 For full list of syscalls:
@@ -85,6 +88,9 @@
 sc_werrstr		//	werrstr(char*, ...);
 };
 
+// User space system call names table -- NCALLS length -- in input.c
+extern char *callnames[NCALLS];
+
 // Structure to track state of system calling
 typedef struct caller caller;
 struct caller
@@ -102,6 +108,6 @@
 /* == Function prototypes == */
 
 // input.c
-void* mkinput(caller);
+void* mkinput(caller*);
 
 #endif
--- a/input.c
+++ b/input.c
@@ -1,14 +1,11 @@
-#include <u.h>
-#include <libc.h>
 #include "fuzz.h"
-#include "mutate.h"
 
 // Procedurally generate input to syscall
 void*
-mkinput(caller sc)
+mkinput(caller *sc)
 {
 	// TODO
-	switch(sc.call) {
+	switch(sc->c) {
 		case sc_exits :			//	_exits(char*);
 		case sc_abort :			//	abort(void);
 		case sc_access :		//	access(char* : int);
@@ -76,7 +73,77 @@
 		case sc_sysname :		//	sysname(void);
 		case sc_werrstr :		//	werrstr(char* : ...);
 		default :
-			#PANIC!
+			exits("Unknown system call!");
 	}
 	return nil;
 }
+
+// Init callnames here, is extern in fuzz.h
+char *callnames[NCALLS]= {
+"_exits",
+"abort",
+"access",
+"alarm",
+"await",
+"bind",
+"brk",
+"chdir",
+"close",
+"create",
+"dup",
+"errstr",
+"exec",
+"execl",
+"fork",
+"rfork",
+"fauth",
+"fstat",
+"fwstat",
+"fversion",
+"mount",
+"unmount",
+"noted",
+"notify",
+"open",
+"fd2path",
+"pipe",
+"pread",
+"preadv",
+"pwrite",
+"pwritev",
+"read",
+"readn",
+"readv",
+"remove",
+"sbrk",
+"oseek",
+"seek",
+"segattach",
+"segbrk",
+"segdetach",
+"segflush",
+"segfree",
+"semacquire",
+"semrelease",
+"sleep",
+"stat",
+"tsemacquire",
+"wait",
+"waitpid",
+"write",
+"writev",
+"wstat",
+"rendezvous",
+"dirstat",
+"dirfstat",
+"dirwstat",
+"dirfwstat",
+"dirread",
+"nulldir",
+"dirreadall",
+"getpid",
+"getppid",
+"rerrstr",
+"sysname",
+"werrstr"
+};
--- a/main.c
+++ b/main.c
@@ -1,5 +1,3 @@
-#include <u.h>
-#include <libc.h>
 #include "fuzz.h"
 
 void
--- a/mkfile
+++ b/mkfile
@@ -6,7 +6,8 @@
 
 OFILES = main.$O \
 		input.$O \
-		list.$O
+		mutate.$O \
+		list.$O 
 
 HFILES = fuzz.h list.h
 
--- /dev/null
+++ b/mutate.c
@@ -1,0 +1,66 @@
+#include "fuzz.h"
+
+void
+mut_int()
+{
+}
+
+void
+mut_uint()
+{
+}
+
+void
+mut_charstar()
+{
+}
+
+void
+mut_ucharstar()
+{
+}
+
+void
+mut_charstar_arr()
+{
+}
+
+void
+mut_long()
+{
+}
+
+void
+mut_longstar()
+{
+}
+
+void
+mut_ulong()
+{
+}
+
+void
+mut_vlong()
+{
+}
+
+void
+mut_voidstar()
+{
+}
+
+void
+mut_IOchunkstar()
+{
+}
+
+void
+mut_dirstar()
+{
+}
+
+void
+mut_dirstar_star()
+{
+}
--- a/mutate.h
+++ b/mutate.h
@@ -1,3 +1,6 @@
+#ifndef MUT_H
+#define MUT_H
+
 void mut_int();
 
 void mut_uint();
@@ -23,3 +26,5 @@
 void mut_dirstar();
 
 void mut_dirstar_star();
+
+#endif