summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-09-26 15:00:42 +0000
committered <ed@FreeBSD.org>2009-09-26 15:00:42 +0000
commit886b080b113cd558f4985cfa6b6ec3a58a751987 (patch)
tree1ed772b24fa970c3d8e0bb028a1d9055a07e7d21 /sys
parent4c721eede82d931b0a694c6f7f52de10132251ac (diff)
downloadFreeBSD-src-886b080b113cd558f4985cfa6b6ec3a58a751987.zip
FreeBSD-src-886b080b113cd558f4985cfa6b6ec3a58a751987.tar.gz
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.
Diffstat (limited to 'sys')
-rw-r--r--sys/teken/teken_stress.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/teken/teken_stress.c b/sys/teken/teken_stress.c
index 40d09bf..1f1c572 100644
--- a/sys/teken/teken_stress.c
+++ b/sys/teken/teken_stress.c
@@ -92,13 +92,16 @@ stress_respond(void *s __unused, const void *buf __unused, size_t len __unused)
{
}
+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[] __unused)
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++;
OpenPOWER on IntegriCloud