summaryrefslogtreecommitdiff
path: root/src/regress/lib
diff options
context:
space:
mode:
authortb <>2022-11-23 08:51:05 +0000
committertb <>2022-11-23 08:51:05 +0000
commitada8f63ac13903c0fcbae23ce5fc73ef9e984da5 (patch)
tree388893d94fa09292a981496cfb41726dbdef3371 /src/regress/lib
parent991cfc6cdb4c08e8a4f31a7a5b698efc412232a6 (diff)
downloadopenbsd-ada8f63ac13903c0fcbae23ce5fc73ef9e984da5.tar.gz
openbsd-ada8f63ac13903c0fcbae23ce5fc73ef9e984da5.tar.bz2
openbsd-ada8f63ac13903c0fcbae23ce5fc73ef9e984da5.zip
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
Diffstat (limited to 'src/regress/lib')
-rw-r--r--src/regress/lib/libcrypto/asn1/asn1_string_to_utf8.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/regress/lib/libcrypto/asn1/asn1_string_to_utf8.c b/src/regress/lib/libcrypto/asn1/asn1_string_to_utf8.c
index 2ead7b46c3..a87969d987 100644
--- a/src/regress/lib/libcrypto/asn1/asn1_string_to_utf8.c
+++ b/src/regress/lib/libcrypto/asn1/asn1_string_to_utf8.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn1_string_to_utf8.c,v 1.1 2022/05/16 20:53:20 tb Exp $ */ 1/* $OpenBSD: asn1_string_to_utf8.c,v 1.2 2022/11/23 08:51:05 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> 3 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
4 * 4 *
@@ -86,12 +86,18 @@ asn1_string_to_utf8_test(const struct asn1_string_to_utf8_test_case *test)
86 goto err; 86 goto err;
87 } 87 }
88 88
89 if ((ret = ASN1_STRING_to_UTF8(&out, str)) != test->want_len) { 89 if ((ret = ASN1_STRING_to_UTF8(&out, str)) < 0) {
90 warnx("ASN1_STRING_to_UTF8 failed: got %d, want %d", ret, 90 warnx("ASN1_STRING_to_UTF8 failed: got %d, want %d", ret,
91 test->want_len); 91 test->want_len);
92 goto err; 92 goto err;
93 } 93 }
94 94
95 if (ret != test->want_len) {
96 warnx("ASN1_STRING_to_UTF8: got %d, want %d", ret,
97 test->want_len);
98 goto err;
99 }
100
95 if (memcmp(out, test->want, test->want_len) != 0) { 101 if (memcmp(out, test->want, test->want_len) != 0) {
96 warnx("memcmp failed"); 102 warnx("memcmp failed");
97 goto err; 103 goto err;