[openssh-commits] [openssh] 16/20: upstream commit
git+noreply at mindrot.org
git+noreply at mindrot.org
Tue Jan 20 00:28:00 EST 2015
This is an automated email from the git hooks/post-receive script.
djm pushed a commit to branch master
in repository openssh.
commit 80603c0daa2538c349c1c152405580b164d5475f
Author: djm at openbsd.org <djm at openbsd.org>
Date: Sun Jan 18 19:52:44 2015 +0000
upstream commit
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
---
regress/unittests/test_helper/fuzz.c | 10 +++++++++-
regress/unittests/test_helper/test_helper.h | 10 +++++++++-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/regress/unittests/test_helper/fuzz.c b/regress/unittests/test_helper/fuzz.c
index 93cff69..06fb247 100644
--- a/regress/unittests/test_helper/fuzz.c
+++ b/regress/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 at mindrot.org>
*
@@ -378,6 +378,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,
diff --git a/regress/unittests/test_helper/test_helper.h b/regress/unittests/test_helper/test_helper.h
index 48c888a..1d9c669 100644
--- a/regress/unittests/test_helper/test_helper.h
+++ b/regress/unittests/test_helper/test_helper.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: test_helper.h,v 1.5 2015/01/15 07:36:28 djm Exp $ */
+/* $OpenBSD: test_helper.h,v 1.6 2015/01/18 19:52:44 djm Exp $ */
/*
* Copyright (c) 2011 Damien Miller <djm at mindrot.org>
*
@@ -283,6 +283,13 @@ void fuzz_cleanup(struct fuzz *fuzz);
/* Prepare the next fuzz case in the series */
void fuzz_next(struct fuzz *fuzz);
+/*
+ * Check whether this fuzz case is identical to the original
+ * This is slow, but useful if the caller needs to ensure that all tests
+ * generated change the input (e.g. when fuzzing signatures).
+ */
+int fuzz_matches_original(struct fuzz *fuzz);
+
/* Determine whether the current fuzz sequence is exhausted (nonzero = yes) */
int fuzz_done(struct fuzz *fuzz);
@@ -292,4 +299,5 @@ u_char *fuzz_ptr(struct fuzz *fuzz);
/* Dump the current fuzz case to stderr */
void fuzz_dump(struct fuzz *fuzz);
+
#endif /* _TEST_HELPER_H */
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list