summaryrefslogtreecommitdiffstats
path: root/regress/usr.bin/ssh/unittests/test_helper/fuzz.c
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2015-01-18 19:52:44 +0000
committerdjm <djm@openbsd.org>2015-01-18 19:52:44 +0000
commit60d08003695c4320e3b392beb0fad1a5db2b8222 (patch)
treef76e48a2fd73be279cdaf7c9c802ba08346e3fc0 /regress/usr.bin/ssh/unittests/test_helper/fuzz.c
parentbetter dumps from the fuzzer (shown on errors) - include the (diff)
downloadwireguard-openbsd-60d08003695c4320e3b392beb0fad1a5db2b8222.tar.xz
wireguard-openbsd-60d08003695c4320e3b392beb0fad1a5db2b8222.zip
add a fuzz_matches_original() function to the fuzzer to
detect fuzz cases that are identical to the original data. Hacky implementation, but very useful when you need the fuzz to be different, e.g. when verifying signature
Diffstat (limited to 'regress/usr.bin/ssh/unittests/test_helper/fuzz.c')
-rw-r--r--regress/usr.bin/ssh/unittests/test_helper/fuzz.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/regress/usr.bin/ssh/unittests/test_helper/fuzz.c b/regress/usr.bin/ssh/unittests/test_helper/fuzz.c
index 2003fbe504f..392783bdabd 100644
--- a/regress/usr.bin/ssh/unittests/test_helper/fuzz.c
+++ b/regress/usr.bin/ssh/unittests/test_helper/fuzz.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fuzz.c,v 1.6 2015/01/18 19:50:55 djm Exp $ */
+/* $OpenBSD: fuzz.c,v 1.7 2015/01/18 19:52:44 djm Exp $ */
/*
* Copyright (c) 2011 Damien Miller <djm@mindrot.org>
*
@@ -374,6 +374,14 @@ fuzz_next(struct fuzz *fuzz)
}
int
+fuzz_matches_original(struct fuzz *fuzz)
+{
+ if (fuzz_len(fuzz) != fuzz->slen)
+ return 0;
+ return memcmp(fuzz_ptr(fuzz), fuzz->seed, fuzz->slen) == 0;
+}
+
+int
fuzz_done(struct fuzz *fuzz)
{
FUZZ_DBG(("fuzz = %p, strategies = 0x%lx", fuzz,