diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2022-07-09 14:46:44 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2022-07-09 14:46:44 +0000 |
commit | 6bd0441b8c0168fe0163386b9930d8cdcd239866 (patch) | |
tree | d1ee63d28795dd7d0b6233b3db437d7a86a1863d /lib/libcrypto/asn1 | |
parent | 3a8b6850aeee8cf93da2caa85951f8dbd088a0d9 (diff) |
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
Diffstat (limited to 'lib/libcrypto/asn1')
-rw-r--r-- | lib/libcrypto/asn1/a_enum.c | 4 | ||||
-rw-r--r-- | lib/libcrypto/asn1/a_int.c | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/libcrypto/asn1/a_enum.c b/lib/libcrypto/asn1/a_enum.c index 11868cef377..3b6cd9f954e 100644 --- a/lib/libcrypto/asn1/a_enum.c +++ b/lib/libcrypto/asn1/a_enum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_enum.c,v 1.24 2022/06/25 16:15:18 jsing Exp $ */ +/* $OpenBSD: a_enum.c,v 1.25 2022/07/09 14:46:43 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -141,6 +141,8 @@ ASN1_ENUMERATED_get(const ASN1_ENUMERATED *aenum) { int64_t val; + if (aenum == NULL) + return 0; if (!ASN1_ENUMERATED_get_int64(&val, aenum)) return -1; if (val < LONG_MIN || val > LONG_MAX) { diff --git a/lib/libcrypto/asn1/a_int.c b/lib/libcrypto/asn1/a_int.c index 38a2e1cfa57..1f1e587d39e 100644 --- a/lib/libcrypto/asn1/a_int.c +++ b/lib/libcrypto/asn1/a_int.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_int.c,v 1.42 2022/06/28 19:44:28 jsing Exp $ */ +/* $OpenBSD: a_int.c,v 1.43 2022/07/09 14:46:42 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -297,6 +297,8 @@ ASN1_INTEGER_get(const ASN1_INTEGER *aint) { int64_t val; + if (aint == NULL) + return 0; if (!ASN1_INTEGER_get_int64(&val, aint)) return -1; if (val < LONG_MIN || val > LONG_MAX) { |