Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Sep 2009 15:00:42 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r197519 - head/sys/teken
Message-ID:  <200909261500.n8QF0gvv062855@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Sat Sep 26 15:00:42 2009
New Revision: 197519
URL: http://svn.freebsd.org/changeset/base/197519

Log:
  Make the fuzzer a bit more useful by forcing 7-bit data into it.
  
  Getting valid UTF-8 sequences is quite unlikely, so we'd better just
  convert data to 7 bits and make it extra likely for escape sequences to
  occur.

Modified:
  head/sys/teken/teken_stress.c

Modified: head/sys/teken/teken_stress.c
==============================================================================
--- head/sys/teken/teken_stress.c	Sat Sep 26 12:45:28 2009	(r197518)
+++ head/sys/teken/teken_stress.c	Sat Sep 26 15:00:42 2009	(r197519)
@@ -92,13 +92,16 @@ stress_respond(void *s __unused, const v
 {
 }
 
+static const char replacement[] =
+    { 0x1b, '[', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ';' };
+
 int
 main(int argc __unused, char *argv[] __unused)
 {
 	teken_t t;
 	int rnd;
-	unsigned int iteration = 0;
-	char buf[2048];
+	unsigned int i, iteration = 0;
+	unsigned char buf[2048];
 
 	rnd = open("/dev/urandom", O_RDONLY);
 	if (rnd < 0) {
@@ -114,6 +117,12 @@ main(int argc __unused, char *argv[] __u
 			exit(1);
 		}
 
+		for (i = 0; i < sizeof buf; i++) {
+			if (buf[i] >= 0x80)
+				buf[i] =
+				    replacement[buf[i] % sizeof replacement];
+		}
+
 		teken_input(&t, buf, sizeof buf);
 
 		iteration++;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909261500.n8QF0gvv062855>