diff options
author | tb <> | 2022-07-09 14:46:43 +0000 |
---|---|---|
committer | tb <> | 2022-07-09 14:46:43 +0000 |
commit | 5c6115e1611e2e3d16709cab84a42dddb77a5125 (patch) | |
tree | 5c650ce686e63356a0cab13dba431952564ce406 | |
parent | b3533f0db329dca3c235838096f69f63de1db987 (diff) | |
download | openbsd-5c6115e1611e2e3d16709cab84a42dddb77a5125.tar.gz openbsd-5c6115e1611e2e3d16709cab84a42dddb77a5125.tar.bz2 openbsd-5c6115e1611e2e3d16709cab84a42dddb77a5125.zip |
Make ASN1_{INTEGER,ENUMERATED}_get() return 0 on NULL again
This is the documented behavior which got lost in the recent rewrite.
Mismatch of documentation and reality pointed out by schwarze
ok jsing
-rw-r--r-- | src/lib/libcrypto/asn1/a_enum.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/a_int.c | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/libcrypto/asn1/a_enum.c b/src/lib/libcrypto/asn1/a_enum.c index 11868cef37..3b6cd9f954 100644 --- a/src/lib/libcrypto/asn1/a_enum.c +++ b/src/lib/libcrypto/asn1/a_enum.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: a_enum.c,v 1.24 2022/06/25 16:15:18 jsing Exp $ */ | 1 | /* $OpenBSD: a_enum.c,v 1.25 2022/07/09 14:46:43 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 | * |
@@ -141,6 +141,8 @@ ASN1_ENUMERATED_get(const ASN1_ENUMERATED *aenum) | |||
141 | { | 141 | { |
142 | int64_t val; | 142 | int64_t val; |
143 | 143 | ||
144 | if (aenum == NULL) | ||
145 | return 0; | ||
144 | if (!ASN1_ENUMERATED_get_int64(&val, aenum)) | 146 | if (!ASN1_ENUMERATED_get_int64(&val, aenum)) |
145 | return -1; | 147 | return -1; |
146 | if (val < LONG_MIN || val > LONG_MAX) { | 148 | if (val < LONG_MIN || val > LONG_MAX) { |
diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c index 38a2e1cfa5..1f1e587d39 100644 --- a/src/lib/libcrypto/asn1/a_int.c +++ b/src/lib/libcrypto/asn1/a_int.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: a_int.c,v 1.42 2022/06/28 19:44:28 jsing Exp $ */ | 1 | /* $OpenBSD: a_int.c,v 1.43 2022/07/09 14:46:42 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 | * |
@@ -297,6 +297,8 @@ ASN1_INTEGER_get(const ASN1_INTEGER *aint) | |||
297 | { | 297 | { |
298 | int64_t val; | 298 | int64_t val; |
299 | 299 | ||
300 | if (aint == NULL) | ||
301 | return 0; | ||
300 | if (!ASN1_INTEGER_get_int64(&val, aint)) | 302 | if (!ASN1_INTEGER_get_int64(&val, aint)) |
301 | return -1; | 303 | return -1; |
302 | if (val < LONG_MIN || val > LONG_MAX) { | 304 | if (val < LONG_MIN || val > LONG_MAX) { |