summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.gitignore2
-rw-r--r--Makefile10
-rw-r--r--term.c14
3 files changed, 26 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 1fe25c1..6b5c3fc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
 *.o
+afl/
 chroot.tar
 config.mk
 dispatch
@@ -8,4 +9,5 @@ root
 setup
 stream
 tags
+term
 view
diff --git a/Makefile b/Makefile
index db34005..0cae642 100644
--- a/Makefile
+++ b/Makefile
@@ -43,3 +43,13 @@ chroot.tar: ${BINS}
 
 clean:
 	rm -fr ${BINS} tags chroot.tar root
+
+fuzz: term afl/input/clear
+	afl-fuzz -i afl/input -o afl/output -- ./term
+
+term: term.c term.h
+	${CC} ${CFLAGS} -DTERM_MAIN ${LDFLAGS} term.c -o term
+
+afl/input/clear:
+	mkdir -p afl/input
+	clear > afl/input/clear
diff --git a/term.c b/term.c
index c77d4f1..a557725 100644
--- a/term.c
+++ b/term.c
@@ -554,3 +554,17 @@ fail:
 	fclose(file);
 	return -1;
 }
+
+#ifdef TERM_MAIN
+#include <locale.h>
+
+int main(void) {
+	setlocale(LC_CTYPE, "");
+	struct Term *term = termAlloc(24, 80);
+	wint_t ch;
+	while (WEOF != (ch = getwchar())) {
+		termUpdate(term, ch);
+	}
+}
+
+#endif