summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/regress/lib/libcrypto/aead/aeadtest.c63
1 files changed, 42 insertions, 21 deletions
diff --git a/src/regress/lib/libcrypto/aead/aeadtest.c b/src/regress/lib/libcrypto/aead/aeadtest.c
index a6a2673320..da2334329f 100644
--- a/src/regress/lib/libcrypto/aead/aeadtest.c
+++ b/src/regress/lib/libcrypto/aead/aeadtest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: aeadtest.c,v 1.17 2022/07/30 14:49:15 jsing Exp $ */ 1/* $OpenBSD: aeadtest.c,v 1.18 2022/07/30 16:12:40 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2014, Google Inc. 3 * Copyright (c) 2014, Google Inc.
4 * 4 *
@@ -306,31 +306,52 @@ main(int argc, char **argv)
306 continue; 306 continue;
307 } 307 }
308 308
309 for (j = 0; line[i] != 0 && line[i] != '\n'; i++) { 309 if (line[i] == '"') {
310 unsigned char v, v2; 310 i++;
311 v = hex_digit(line[i++]); 311 for (j = 0; line[i] != 0 && line[i] != '\n'; i++) {
312 if (line[i] == 0 || line[i] == '\n') { 312 if (line[i] == '"')
313 fprintf(stderr, "Odd-length hex data on " 313 break;
314 "line %u\n", line_no); 314 if (j == BUF_MAX) {
315 return 3; 315 fprintf(stderr, "Too much data on "
316 "line %u (max is %u bytes)\n",
317 line_no, (unsigned) BUF_MAX);
318 return 3;
319 }
320 buf[j++] = line[i];
321 *buf_len = *buf_len + 1;
316 } 322 }
317 v2 = hex_digit(line[i]); 323 if (line[i + 1] != 0 && line[i + 1] != '\n') {
318 if (v > 15 || v2 > 15) { 324 fprintf(stderr, "Trailing data on line %u\n",
319 fprintf(stderr, "Invalid hex char on line %u\n",
320 line_no); 325 line_no);
321 return 3; 326 return 3;
322 } 327 }
323 v <<= 4; 328 } else {
324 v |= v2; 329 for (j = 0; line[i] != 0 && line[i] != '\n'; i++) {
325 330 unsigned char v, v2;
326 if (j == BUF_MAX) { 331 v = hex_digit(line[i++]);
327 fprintf(stderr, "Too much hex data on line %u " 332 if (line[i] == 0 || line[i] == '\n') {
328 "(max is %u bytes)\n", 333 fprintf(stderr, "Odd-length hex data "
329 line_no, (unsigned) BUF_MAX); 334 "on line %u\n", line_no);
330 return 3; 335 return 3;
336 }
337 v2 = hex_digit(line[i]);
338 if (v > 15 || v2 > 15) {
339 fprintf(stderr, "Invalid hex char on "
340 "line %u\n", line_no);
341 return 3;
342 }
343 v <<= 4;
344 v |= v2;
345
346 if (j == BUF_MAX) {
347 fprintf(stderr, "Too much hex data on "
348 "line %u (max is %u bytes)\n",
349 line_no, (unsigned) BUF_MAX);
350 return 3;
351 }
352 buf[j++] = v;
353 *buf_len = *buf_len + 1;
331 } 354 }
332 buf[j++] = v;
333 *buf_len = *buf_len + 1;
334 } 355 }
335 } 356 }
336 357