diff options
| author | tb <> | 2023-03-10 09:56:09 +0000 |
|---|---|---|
| committer | tb <> | 2023-03-10 09:56:09 +0000 |
| commit | 72196349be7c62460f3c81bbcf4f357d46ba91de (patch) | |
| tree | 567c9f4485e429cbc9cde9f58e0a77318fe5d88b /src | |
| parent | e618485baac7a3a801239050e123640f8895eac9 (diff) | |
| download | openbsd-72196349be7c62460f3c81bbcf4f357d46ba91de.tar.gz openbsd-72196349be7c62460f3c81bbcf4f357d46ba91de.tar.bz2 openbsd-72196349be7c62460f3c81bbcf4f357d46ba91de.zip | |
Return the correct type for ASN.1 BOOLEANs
ASN.1 BOOLEANs and ASN.1 NULL are handled specially in the ASN.1 sausage
factory and they are special in that they don't have a->value.ptr set.
Both need to be special cased here since they fail the a->type.ptr != NULL
check.
Apart from fixing an obvious bug in ASN1_TYPE_get(), this fixes another
crash in openssl(1) asn1parse. There is more to do in the vicinity, but
that is more complex and will have to wait for OpenBSD 7.3-current.
with/ok jsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/asn1/a_type.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/lib/libcrypto/asn1/a_type.c b/src/lib/libcrypto/asn1/a_type.c index 61609c38f7..684321756f 100644 --- a/src/lib/libcrypto/asn1/a_type.c +++ b/src/lib/libcrypto/asn1/a_type.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: a_type.c,v 1.23 2021/12/25 12:19:16 jsing Exp $ */ | 1 | /* $OpenBSD: a_type.c,v 1.24 2023/03/10 09:56:09 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 | * |
| @@ -104,10 +104,14 @@ ASN1_TYPE_free(ASN1_TYPE *a) | |||
| 104 | int | 104 | int |
| 105 | ASN1_TYPE_get(const ASN1_TYPE *a) | 105 | ASN1_TYPE_get(const ASN1_TYPE *a) |
| 106 | { | 106 | { |
| 107 | if ((a->value.ptr != NULL) || (a->type == V_ASN1_NULL)) | 107 | /* Special non-pointer types. */ |
| 108 | return (a->type); | 108 | if (a->type == V_ASN1_BOOLEAN || a->type == V_ASN1_NULL ) |
| 109 | else | 109 | return a->type; |
| 110 | return (0); | 110 | |
| 111 | if (a->value.ptr != NULL) | ||
| 112 | return a->type; | ||
| 113 | |||
| 114 | return 0; | ||
| 111 | } | 115 | } |
| 112 | 116 | ||
| 113 | void | 117 | void |
