Fix memory leak in s2i_ASN_INTEGER and return an error
if any invalid characters are present.
This commit is contained in:
parent
137e7e3aa1
commit
2232e262bf
@ -156,11 +156,11 @@ ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, char *value)
|
|||||||
ASN1_INTEGER *aint;
|
ASN1_INTEGER *aint;
|
||||||
int isneg, ishex;
|
int isneg, ishex;
|
||||||
int ret;
|
int ret;
|
||||||
bn = BN_new();
|
|
||||||
if (!value) {
|
if (!value) {
|
||||||
X509V3err(X509V3_F_S2I_ASN1_INTEGER,X509V3_R_INVALID_NULL_VALUE);
|
X509V3err(X509V3_F_S2I_ASN1_INTEGER,X509V3_R_INVALID_NULL_VALUE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
bn = BN_new();
|
||||||
if (value[0] == '-') {
|
if (value[0] == '-') {
|
||||||
value++;
|
value++;
|
||||||
isneg = 1;
|
isneg = 1;
|
||||||
@ -174,7 +174,8 @@ ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, char *value)
|
|||||||
if (ishex) ret = BN_hex2bn(&bn, value);
|
if (ishex) ret = BN_hex2bn(&bn, value);
|
||||||
else ret = BN_dec2bn(&bn, value);
|
else ret = BN_dec2bn(&bn, value);
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret || value[ret]) {
|
||||||
|
BN_free(bn);
|
||||||
X509V3err(X509V3_F_S2I_ASN1_INTEGER,X509V3_R_BN_DEC2BN_ERROR);
|
X509V3err(X509V3_F_S2I_ASN1_INTEGER,X509V3_R_BN_DEC2BN_ERROR);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user