From 80603c0daa2538c349c1c152405580b164d5475f Mon Sep 17 00:00:00 2001 From: "djm@openbsd.org" Date: Sun, 18 Jan 2015 19:52:44 +0000 Subject: 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 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'regress/unittests/test_helper/fuzz.c') diff --git a/regress/unittests/test_helper/fuzz.c b/regress/unittests/test_helper/fuzz.c index 93cff6969..06fb247ef 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 * @@ -377,6 +377,14 @@ fuzz_next(struct fuzz *fuzz) (u_long)fuzz->strategies, fuzz->o1, fuzz->o2, fuzz->slen)); } +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) { -- cgit v1.2.3