OpenSSL 1.1.1-pre2
This commit is contained in:
+32
-25
@@ -23,12 +23,12 @@ static int _asn1_check_infinite_end(const unsigned char **p, long len)
|
||||
* If there is 0 or 1 byte left, the length check should pick things up
|
||||
*/
|
||||
if (len <= 0)
|
||||
return (1);
|
||||
return 1;
|
||||
else if ((len >= 2) && ((*p)[0] == 0) && ((*p)[1] == 0)) {
|
||||
(*p) += 2;
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ASN1_check_infinite_end(unsigned char **p, long len)
|
||||
@@ -96,47 +96,54 @@ int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
|
||||
ret |= 0x80;
|
||||
}
|
||||
*pp = p;
|
||||
return (ret | inf);
|
||||
return ret | inf;
|
||||
err:
|
||||
ASN1err(ASN1_F_ASN1_GET_OBJECT, ASN1_R_HEADER_TOO_LONG);
|
||||
return (0x80);
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decode a length field.
|
||||
* The short form is a single byte defining a length 0 - 127.
|
||||
* The long form is a byte 0 - 127 with the top bit set and this indicates
|
||||
* the number of following octets that contain the length. These octets
|
||||
* are stored most significant digit first.
|
||||
*/
|
||||
static int asn1_get_length(const unsigned char **pp, int *inf, long *rl,
|
||||
long max)
|
||||
{
|
||||
const unsigned char *p = *pp;
|
||||
unsigned long ret = 0;
|
||||
unsigned long i;
|
||||
int i;
|
||||
|
||||
if (max-- < 1)
|
||||
return 0;
|
||||
if (*p == 0x80) {
|
||||
*inf = 1;
|
||||
ret = 0;
|
||||
p++;
|
||||
} else {
|
||||
*inf = 0;
|
||||
i = *p & 0x7f;
|
||||
if (*(p++) & 0x80) {
|
||||
if (max < (long)i + 1)
|
||||
if (*p++ & 0x80) {
|
||||
if (max < i + 1)
|
||||
return 0;
|
||||
/* Skip leading zeroes */
|
||||
while (i && *p == 0) {
|
||||
while (i > 0 && *p == 0) {
|
||||
p++;
|
||||
i--;
|
||||
}
|
||||
if (i > sizeof(long))
|
||||
if (i > (int)sizeof(long))
|
||||
return 0;
|
||||
while (i-- > 0) {
|
||||
ret <<= 8L;
|
||||
ret |= *(p++);
|
||||
while (i > 0) {
|
||||
ret <<= 8;
|
||||
ret |= *p++;
|
||||
i--;
|
||||
}
|
||||
if (ret > LONG_MAX)
|
||||
return 0;
|
||||
} else
|
||||
ret = i;
|
||||
}
|
||||
if (ret > LONG_MAX)
|
||||
return 0;
|
||||
*pp = p;
|
||||
*rl = (long)ret;
|
||||
return 1;
|
||||
@@ -268,7 +275,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
|
||||
|
||||
if (len < 0) {
|
||||
if (data == NULL)
|
||||
return (0);
|
||||
return 0;
|
||||
else
|
||||
len = strlen(data);
|
||||
}
|
||||
@@ -278,7 +285,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
|
||||
if (str->data == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE);
|
||||
str->data = c;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
str->length = len;
|
||||
@@ -287,7 +294,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
|
||||
/* an allowance for strings :-) */
|
||||
str->data[len] = '\0';
|
||||
}
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)
|
||||
@@ -299,7 +306,7 @@ void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)
|
||||
|
||||
ASN1_STRING *ASN1_STRING_new(void)
|
||||
{
|
||||
return (ASN1_STRING_type_new(V_ASN1_OCTET_STRING));
|
||||
return ASN1_STRING_type_new(V_ASN1_OCTET_STRING);
|
||||
}
|
||||
|
||||
ASN1_STRING *ASN1_STRING_type_new(int type)
|
||||
@@ -309,10 +316,10 @@ ASN1_STRING *ASN1_STRING_type_new(int type)
|
||||
ret = OPENSSL_zalloc(sizeof(*ret));
|
||||
if (ret == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
ret->type = type;
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void asn1_string_embed_free(ASN1_STRING *a, int embed)
|
||||
@@ -349,11 +356,11 @@ int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
|
||||
if (i == 0) {
|
||||
i = memcmp(a->data, b->data, a->length);
|
||||
if (i == 0)
|
||||
return (a->type - b->type);
|
||||
return a->type - b->type;
|
||||
else
|
||||
return (i);
|
||||
return i;
|
||||
} else
|
||||
return (i);
|
||||
return i;
|
||||
}
|
||||
|
||||
int ASN1_STRING_length(const ASN1_STRING *x)
|
||||
|
||||
Reference in New Issue
Block a user