diff options
author | tb <> | 2022-05-16 20:41:24 +0000 |
---|---|---|
committer | tb <> | 2022-05-16 20:41:24 +0000 |
commit | 9d6ef43f022edfa4ee989dd7861fa804f2c9b61e (patch) | |
tree | 7a75d8652b4b012bd3e13746ca4598434325ae7a | |
parent | 4d98507bd8898b13bbd0d1ab339f3d35695e06a9 (diff) | |
download | openbsd-9d6ef43f022edfa4ee989dd7861fa804f2c9b61e.tar.gz openbsd-9d6ef43f022edfa4ee989dd7861fa804f2c9b61e.tar.bz2 openbsd-9d6ef43f022edfa4ee989dd7861fa804f2c9b61e.zip |
Avoid use of uninitialized in ASN1_STRING_to_UTF8()
A long standing failure to initialize a struct on the stack fully was
exposed by a recent refactoring. Fortunately, the uninitialized 'flag'
member is only used to decide whether or not to call freezero(NULL, 0),
so it is completely harmless. This is a first trivial fix, a better
version will be landed separately with regress.
Reported by Steffen Jaeckel, GH #760
ok beck
-rw-r--r-- | src/lib/libcrypto/asn1/a_string.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lib/libcrypto/asn1/a_string.c b/src/lib/libcrypto/asn1/a_string.c index 90e363e9c7..9086d3bec8 100644 --- a/src/lib/libcrypto/asn1/a_string.c +++ b/src/lib/libcrypto/asn1/a_string.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: a_string.c,v 1.7 2022/03/17 17:17:58 jsing Exp $ */ | 1 | /* $OpenBSD: a_string.c,v 1.8 2022/05/16 20:41:24 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -276,7 +276,8 @@ ASN1_STRING_print(BIO *bp, const ASN1_STRING *astr) | |||
276 | int | 276 | int |
277 | ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in) | 277 | ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in) |
278 | { | 278 | { |
279 | ASN1_STRING stmp, *str = &stmp; | 279 | ASN1_STRING stmp = { 0 }; |
280 | ASN1_STRING *str = &stmp; | ||
280 | int mbflag, ret; | 281 | int mbflag, ret; |
281 | 282 | ||
282 | if (in == NULL) | 283 | if (in == NULL) |
@@ -287,8 +288,6 @@ ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in) | |||
287 | 288 | ||
288 | mbflag |= MBSTRING_FLAG; | 289 | mbflag |= MBSTRING_FLAG; |
289 | 290 | ||
290 | stmp.data = NULL; | ||
291 | stmp.length = 0; | ||
292 | ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, | 291 | ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, |
293 | B_ASN1_UTF8STRING); | 292 | B_ASN1_UTF8STRING); |
294 | if (ret < 0) | 293 | if (ret < 0) |