diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/asn1_lib.c')
-rw-r--r-- | src/lib/libcrypto/asn1/asn1_lib.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lib/libcrypto/asn1/asn1_lib.c b/src/lib/libcrypto/asn1/asn1_lib.c index 422685a3b4..0638870ab7 100644 --- a/src/lib/libcrypto/asn1/asn1_lib.c +++ b/src/lib/libcrypto/asn1/asn1_lib.c | |||
@@ -57,6 +57,7 @@ | |||
57 | */ | 57 | */ |
58 | 58 | ||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include <limits.h> | ||
60 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
61 | #include <openssl/asn1.h> | 62 | #include <openssl/asn1.h> |
62 | #include <openssl/asn1_mac.h> | 63 | #include <openssl/asn1_mac.h> |
@@ -124,7 +125,7 @@ int ASN1_get_object(unsigned char **pp, long *plength, int *ptag, int *pclass, | |||
124 | (int)(omax+ *pp)); | 125 | (int)(omax+ *pp)); |
125 | 126 | ||
126 | #endif | 127 | #endif |
127 | if (*plength > (omax - (*pp - p))) | 128 | if (*plength > (omax - (p - *pp))) |
128 | { | 129 | { |
129 | ASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_TOO_LONG); | 130 | ASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_TOO_LONG); |
130 | /* Set this so that even if things are not long enough | 131 | /* Set this so that even if things are not long enough |
@@ -141,7 +142,7 @@ err: | |||
141 | static int asn1_get_length(unsigned char **pp, int *inf, long *rl, int max) | 142 | static int asn1_get_length(unsigned char **pp, int *inf, long *rl, int max) |
142 | { | 143 | { |
143 | unsigned char *p= *pp; | 144 | unsigned char *p= *pp; |
144 | long ret=0; | 145 | unsigned long ret=0; |
145 | int i; | 146 | int i; |
146 | 147 | ||
147 | if (max-- < 1) return(0); | 148 | if (max-- < 1) return(0); |
@@ -170,10 +171,10 @@ static int asn1_get_length(unsigned char **pp, int *inf, long *rl, int max) | |||
170 | else | 171 | else |
171 | ret=i; | 172 | ret=i; |
172 | } | 173 | } |
173 | if (ret < 0) | 174 | if (ret > LONG_MAX) |
174 | return 0; | 175 | return 0; |
175 | *pp=p; | 176 | *pp=p; |
176 | *rl=ret; | 177 | *rl=(long)ret; |
177 | return(1); | 178 | return(1); |
178 | } | 179 | } |
179 | 180 | ||