aboutsummaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2002-08-02 18:48:55 +0000
committerDr. Stephen Henson <steve@openssl.org>2002-08-02 18:48:55 +0000
commitf90822689891ca5150f71f8f0502d1877f10faa4 (patch)
treeca850f6429f1d57bd1ff11ce3d435352922081b9 /crypto
parent909abce8002bf6babc42b8196c812f738d8cd0d6 (diff)
downloadopenssl-f90822689891ca5150f71f8f0502d1877f10faa4.zip
openssl-f90822689891ca5150f71f8f0502d1877f10faa4.tar.gz
openssl-f90822689891ca5150f71f8f0502d1877f10faa4.tar.bz2
Fix the ASN1 sanity check: correct header length
calculation and check overflow against LONG_MAX.
Diffstat (limited to 'crypto')
-rw-r--r--crypto/asn1/asn1_lib.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c
index 422685a..f8b636c 100644
--- a/crypto/asn1/asn1_lib.c
+++ b/crypto/asn1/asn1_lib.c
@@ -57,6 +57,7 @@
*/
#include <stdio.h>
+#include <limits.h>
#include "cryptlib.h"
#include <openssl/asn1.h>
#include <openssl/asn1_mac.h>
@@ -124,7 +125,7 @@ int ASN1_get_object(unsigned char **pp, long *plength, int *ptag, int *pclass,
(int)(omax+ *pp));
#endif
- if (*plength > (omax - (*pp - p)))
+ if (*plength > (omax - (*p - *pp)))
{
ASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_TOO_LONG);
/* Set this so that even if things are not long enough
@@ -141,7 +142,7 @@ err:
static int asn1_get_length(unsigned char **pp, int *inf, long *rl, int max)
{
unsigned char *p= *pp;
- long ret=0;
+ unsigned long ret=0;
int i;
if (max-- < 1) return(0);
@@ -170,10 +171,10 @@ static int asn1_get_length(unsigned char **pp, int *inf, long *rl, int max)
else
ret=i;
}
- if (ret < 0)
+ if (ret > LONG_MAX)
return 0;
*pp=p;
- *rl=ret;
+ *rl=(long)ret;
return(1);
}