summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2015-01-18 19:50:55 +0000
committerDamien Miller <djm@mindrot.org>2015-01-20 00:24:39 +1100
commit87d5495bd337e358ad69c524fcb9495208c0750b (patch)
tree41c3834b521a1c47ad0b3127450109524e086755 /regress
parentd59ec478c453a3fff05badbbfd96aa856364f2c2 (diff)
upstream commit
better dumps from the fuzzer (shown on errors) - include the original data as well as the fuzzed copy.
Diffstat (limited to 'regress')
-rw-r--r--regress/unittests/test_helper/fuzz.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/regress/unittests/test_helper/fuzz.c b/regress/unittests/test_helper/fuzz.c
index 963bce3dc..93cff6969 100644
--- a/regress/unittests/test_helper/fuzz.c
+++ b/regress/unittests/test_helper/fuzz.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: fuzz.c,v 1.5 2015/01/13 14:51:51 djm Exp $ */ 1/* $OpenBSD: fuzz.c,v 1.6 2015/01/18 19:50:55 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2011 Damien Miller <djm@mindrot.org> 3 * Copyright (c) 2011 Damien Miller <djm@mindrot.org>
4 * 4 *
@@ -154,19 +154,11 @@ fuzz_fmt(struct fuzz *fuzz, char *s, size_t n)
154 } 154 }
155} 155}
156 156
157void 157static void
158fuzz_dump(struct fuzz *fuzz) 158dump(u_char *p, size_t len)
159{ 159{
160 u_char *p = fuzz_ptr(fuzz); 160 size_t i, j;
161 size_t i, j, len = fuzz_len(fuzz);
162 char buf[256];
163 161
164 if (fuzz_fmt(fuzz, buf, sizeof(buf)) != 0) {
165 fprintf(stderr, "%s: fuzz invalid\n", __func__);
166 abort();
167 }
168 fputs(buf, stderr);
169 fprintf(stderr, "fuzz context %p len = %zu\n", fuzz, len);
170 for (i = 0; i < len; i += 16) { 162 for (i = 0; i < len; i += 16) {
171 fprintf(stderr, "%.4zd: ", i); 163 fprintf(stderr, "%.4zd: ", i);
172 for (j = i; j < i + 16; j++) { 164 for (j = i; j < i + 16; j++) {
@@ -188,6 +180,22 @@ fuzz_dump(struct fuzz *fuzz)
188 } 180 }
189} 181}
190 182
183void
184fuzz_dump(struct fuzz *fuzz)
185{
186 char buf[256];
187
188 if (fuzz_fmt(fuzz, buf, sizeof(buf)) != 0) {
189 fprintf(stderr, "%s: fuzz invalid\n", __func__);
190 abort();
191 }
192 fputs(buf, stderr);
193 fprintf(stderr, "fuzz original %p len = %zu\n", fuzz->seed, fuzz->slen);
194 dump(fuzz->seed, fuzz->slen);
195 fprintf(stderr, "fuzz context %p len = %zu\n", fuzz, fuzz_len(fuzz));
196 dump(fuzz_ptr(fuzz), fuzz_len(fuzz));
197}
198
191#ifdef SIGINFO 199#ifdef SIGINFO
192static struct fuzz *last_fuzz; 200static struct fuzz *last_fuzz;
193 201