diff options
Diffstat (limited to 'regress/unittests/test_helper/fuzz.c')
-rw-r--r-- | regress/unittests/test_helper/fuzz.c | 32 |
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 | ||
157 | void | 157 | static void |
158 | fuzz_dump(struct fuzz *fuzz) | 158 | dump(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 | ||
183 | void | ||
184 | fuzz_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 |
192 | static struct fuzz *last_fuzz; | 200 | static struct fuzz *last_fuzz; |
193 | 201 | ||