mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-29 16:44:03 +00:00
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.
This commit is contained in:
parent
4507f02e0e
commit
a78f7fafc0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=197519
@ -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++;
|
||||
|
Loading…
Reference in New Issue
Block a user