svn commit: r197519 - head/sys/teken
Ed Schouten
ed at FreeBSD.org
Sat Sep 26 15:00:42 UTC 2009
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++;
More information about the svn-src-head
mailing list