diff options
| author | bcook <> | 2015-07-18 21:57:00 +0000 |
|---|---|---|
| committer | bcook <> | 2015-07-18 21:57:00 +0000 |
| commit | 0754ae5beb3c90c42a4f025ab0840aca20f65390 (patch) | |
| tree | b27e3da0524515deb7b514de64569d3c5d79d0ea | |
| parent | 7510bf41ec4cdda3b3749905b51625fff4d6979e (diff) | |
| download | openbsd-0754ae5beb3c90c42a4f025ab0840aca20f65390.tar.gz openbsd-0754ae5beb3c90c42a4f025ab0840aca20f65390.tar.bz2 openbsd-0754ae5beb3c90c42a4f025ab0840aca20f65390.zip | |
simplify length checking in do_indefinite_convert
Fixes Coverity 117506, 117507, 117508
ok doug@
Diffstat (limited to '')
| -rw-r--r-- | src/regress/lib/libssl/bytestring/bytestringtest.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/regress/lib/libssl/bytestring/bytestringtest.c b/src/regress/lib/libssl/bytestring/bytestringtest.c index 3275e6f2c7..808fd0cc87 100644 --- a/src/regress/lib/libssl/bytestring/bytestringtest.c +++ b/src/regress/lib/libssl/bytestring/bytestringtest.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bytestringtest.c,v 1.8 2015/06/23 05:58:28 doug Exp $ */ | 1 | /* $OpenBSD: bytestringtest.c,v 1.9 2015/07/18 21:57:00 bcook Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
| 4 | * | 4 | * |
| @@ -25,18 +25,19 @@ | |||
| 25 | /* This is from <openssl/base.h> in boringssl */ | 25 | /* This is from <openssl/base.h> in boringssl */ |
| 26 | #define OPENSSL_U64(x) x##ULL | 26 | #define OPENSSL_U64(x) x##ULL |
| 27 | 27 | ||
| 28 | #define PRINT_ERROR printf("Error in %s [%s:%d]\n", __func__, __FILE__, \ | ||
| 29 | __LINE__) | ||
| 30 | |||
| 28 | #define CHECK(a) do { \ | 31 | #define CHECK(a) do { \ |
| 29 | if (!(a)) { \ | 32 | if (!(a)) { \ |
| 30 | printf("Error in %s [%s:%d]\n", __func__, __FILE__, \ | 33 | PRINT_ERROR; \ |
| 31 | __LINE__); \ | ||
| 32 | return 0; \ | 34 | return 0; \ |
| 33 | } \ | 35 | } \ |
| 34 | } while (0) | 36 | } while (0) |
| 35 | 37 | ||
| 36 | #define CHECK_GOTO(a) do { \ | 38 | #define CHECK_GOTO(a) do { \ |
| 37 | if (!(a)) { \ | 39 | if (!(a)) { \ |
| 38 | printf("Error in %s [%s:%d]\n", __func__, __FILE__, \ | 40 | PRINT_ERROR; \ |
| 39 | __LINE__); \ | ||
| 40 | goto err; \ | 41 | goto err; \ |
| 41 | } \ | 42 | } \ |
| 42 | } while (0) | 43 | } while (0) |
| @@ -511,18 +512,23 @@ do_indefinite_convert(const char *name, const uint8_t *definite_expected, | |||
| 511 | CHECK_GOTO(CBS_asn1_indefinite_to_definite(&in, &out, &out_len)); | 512 | CHECK_GOTO(CBS_asn1_indefinite_to_definite(&in, &out, &out_len)); |
| 512 | 513 | ||
| 513 | if (out == NULL) { | 514 | if (out == NULL) { |
| 514 | CHECK_GOTO(indefinite_len == definite_len); | 515 | |
| 515 | CHECK_GOTO(memcmp(definite_expected, indefinite, indefinite_len) | 516 | if (indefinite_len != definite_len || |
| 516 | == 0); | 517 | memcmp(definite_expected, indefinite, indefinite_len) != 0) { |
| 518 | PRINT_ERROR; | ||
| 519 | goto err; | ||
| 520 | } | ||
| 517 | 521 | ||
| 518 | return 1; | 522 | return 1; |
| 519 | } | 523 | } |
| 520 | 524 | ||
| 521 | CHECK_GOTO(out_len == definite_len); | 525 | if (out_len != definite_len || |
| 522 | CHECK_GOTO(memcmp(out, definite_expected, definite_len) == 0); | 526 | memcmp(out, definite_expected, definite_len) != 0) { |
| 527 | PRINT_ERROR; | ||
| 528 | goto err; | ||
| 529 | } | ||
| 523 | 530 | ||
| 524 | ret = 1; | 531 | ret = 1; |
| 525 | |||
| 526 | err: | 532 | err: |
| 527 | free(out); | 533 | free(out); |
| 528 | return ret; | 534 | return ret; |
