diff options
-rw-r--r-- | src/regress/lib/libcrypto/base64/base64test.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/regress/lib/libcrypto/base64/base64test.c b/src/regress/lib/libcrypto/base64/base64test.c index 1ff3b93002..9b8ac91e72 100644 --- a/src/regress/lib/libcrypto/base64/base64test.c +++ b/src/regress/lib/libcrypto/base64/base64test.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: base64test.c,v 1.6 2019/06/27 04:29:35 deraadt Exp $ */ | 1 | /* $OpenBSD: base64test.c,v 1.7 2020/03/10 11:10:53 inoguchi Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -221,7 +221,9 @@ base64_encoding_test(int test_no, struct base64_test *bt, int test_nl) | |||
221 | 221 | ||
222 | b64len = 0; | 222 | b64len = 0; |
223 | for (i = 0; i < bt->out_len; i++) { | 223 | for (i = 0; i < bt->out_len; i++) { |
224 | if (bt->out[i] == '\r' || bt->out[i] == '\n') | 224 | if ((!test_nl || |
225 | (test_nl && (i % 64 != 0 || i == bt->out_len - 1))) && | ||
226 | (bt->out[i] == '\r' || bt->out[i] == '\n')) | ||
225 | continue; | 227 | continue; |
226 | buf[b64len++] = bt->out[i]; | 228 | buf[b64len++] = bt->out[i]; |
227 | } | 229 | } |
@@ -273,14 +275,15 @@ base64_decoding_test(int test_no, struct base64_test *bt, int test_nl) | |||
273 | if (buf == NULL) | 275 | if (buf == NULL) |
274 | errx(1, "malloc"); | 276 | errx(1, "malloc"); |
275 | 277 | ||
276 | input = (char *)bt->out; | 278 | if ((input = malloc(BUF_SIZE)) == NULL) |
277 | inlen = bt->out_len; | 279 | errx(1, "malloc"); |
278 | |||
279 | if (test_nl) | ||
280 | inlen = asprintf(&input, "%s\r\n", bt->out); | ||
281 | 280 | ||
282 | if (inlen == -1) | 281 | memcpy(input, bt->out, bt->out_len); |
283 | errx(1, "asprintf"); | 282 | inlen = bt->out_len; |
283 | if (test_nl) { | ||
284 | memcpy(&input[bt->out_len], "\r\n", 2); | ||
285 | inlen += 2; | ||
286 | } | ||
284 | 287 | ||
285 | bio_mem = BIO_new_mem_buf(input, inlen); | 288 | bio_mem = BIO_new_mem_buf(input, inlen); |
286 | if (bio_mem == NULL) | 289 | if (bio_mem == NULL) |
@@ -326,8 +329,8 @@ base64_decoding_test(int test_no, struct base64_test *bt, int test_nl) | |||
326 | fprintf(stderr, "0x%x ", buf[i]); | 329 | fprintf(stderr, "0x%x ", buf[i]); |
327 | fprintf(stderr, "\n"); | 330 | fprintf(stderr, "\n"); |
328 | fprintf(stderr, " test data: "); | 331 | fprintf(stderr, " test data: "); |
329 | for (i = 0; i < inlen; i++) | 332 | for (i = 0; i < bt->in_len; i++) |
330 | fprintf(stderr, "0x%x ", input[i]); | 333 | fprintf(stderr, "0x%x ", bt->in[i]); |
331 | fprintf(stderr, "\n"); | 334 | fprintf(stderr, "\n"); |
332 | failure = 1; | 335 | failure = 1; |
333 | } | 336 | } |