diff options
author | tb <> | 2019-04-28 05:05:56 +0000 |
---|---|---|
committer | tb <> | 2019-04-28 05:05:56 +0000 |
commit | 3d5d777847c4c3150ded4c8ec6e62798a116c542 (patch) | |
tree | e81237114b285e73f99ad08a0aba4a262625c074 | |
parent | e11485d8aaf3818801c1c7586a97a34ef5230be9 (diff) | |
download | openbsd-3d5d777847c4c3150ded4c8ec6e62798a116c542.tar.gz openbsd-3d5d777847c4c3150ded4c8ec6e62798a116c542.tar.bz2 openbsd-3d5d777847c4c3150ded4c8ec6e62798a116c542.zip |
Avoid an undefined shift in ASN1_ENUMERATED_get().
(same fix as in a_int.c rev 1.34)
Fixes oss-fuzz issue #13809
ok beck, jsing
-rw-r--r-- | src/lib/libcrypto/asn1/a_enum.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lib/libcrypto/asn1/a_enum.c b/src/lib/libcrypto/asn1/a_enum.c index c7d3a9a0ac..0952e049db 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.19 2018/04/25 11:48:21 tb Exp $ */ | 1 | /* $OpenBSD: a_enum.c,v 1.20 2019/04/28 05:05:56 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 | * |
@@ -56,6 +56,7 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #include <limits.h> | ||
59 | #include <stdio.h> | 60 | #include <stdio.h> |
60 | 61 | ||
61 | #include <openssl/asn1.h> | 62 | #include <openssl/asn1.h> |
@@ -107,7 +108,7 @@ long | |||
107 | ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a) | 108 | ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a) |
108 | { | 109 | { |
109 | int neg = 0, i; | 110 | int neg = 0, i; |
110 | long r = 0; | 111 | unsigned long r = 0; |
111 | 112 | ||
112 | if (a == NULL) | 113 | if (a == NULL) |
113 | return (0L); | 114 | return (0L); |
@@ -128,9 +129,13 @@ ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a) | |||
128 | r <<= 8; | 129 | r <<= 8; |
129 | r |= (unsigned char)a->data[i]; | 130 | r |= (unsigned char)a->data[i]; |
130 | } | 131 | } |
132 | |||
133 | if (r > LONG_MAX) | ||
134 | return -1; | ||
135 | |||
131 | if (neg) | 136 | if (neg) |
132 | r = -r; | 137 | return -(long)r; |
133 | return (r); | 138 | return (long)r; |
134 | } | 139 | } |
135 | 140 | ||
136 | ASN1_ENUMERATED * | 141 | ASN1_ENUMERATED * |