diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2022-11-23 08:51:06 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2022-11-23 08:51:06 +0000 |
commit | 616e24e680a3aeb51639362c284817fbd3532b6f (patch) | |
tree | eedefe306a723ec33c0c62aa5283a8c6e0bf9623 | |
parent | 96e9d5b710633ed02e830fb5bc044108f3788b68 (diff) |
asn1_string_to_utf8 test: appease coverity
Check for ASN_STRING_to_UTF8() failure before checking it matches our
expectations. This should convey clearly that test->want_len is never
negative.
CID 377011
Diagnosed by jsing
-rw-r--r-- | regress/lib/libcrypto/asn1/asn1_string_to_utf8.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/regress/lib/libcrypto/asn1/asn1_string_to_utf8.c b/regress/lib/libcrypto/asn1/asn1_string_to_utf8.c index 2ead7b46c3b..a87969d987f 100644 --- a/regress/lib/libcrypto/asn1/asn1_string_to_utf8.c +++ b/regress/lib/libcrypto/asn1/asn1_string_to_utf8.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_string_to_utf8.c,v 1.1 2022/05/16 20:53:20 tb Exp $ */ +/* $OpenBSD: asn1_string_to_utf8.c,v 1.2 2022/11/23 08:51:05 tb Exp $ */ /* * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> * @@ -86,12 +86,18 @@ asn1_string_to_utf8_test(const struct asn1_string_to_utf8_test_case *test) goto err; } - if ((ret = ASN1_STRING_to_UTF8(&out, str)) != test->want_len) { + if ((ret = ASN1_STRING_to_UTF8(&out, str)) < 0) { warnx("ASN1_STRING_to_UTF8 failed: got %d, want %d", ret, test->want_len); goto err; } + if (ret != test->want_len) { + warnx("ASN1_STRING_to_UTF8: got %d, want %d", ret, + test->want_len); + goto err; + } + if (memcmp(out, test->want, test->want_len) != 0) { warnx("memcmp failed"); goto err; |