From: Pauli Date: Sun, 4 Apr 2021 03:58:22 +0000 (+1000) Subject: Ensure that the negative flag is correct set for ASN1 integer types. X-Git-Tag: openssl-3.0.0-alpha14~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=581c4b1d5357bdf858a6675ea0b3121731bca5c3;p=thirdparty%2Fopenssl.git Ensure that the negative flag is correct set for ASN1 integer types. Reported by: Scott McPeak Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/14768) --- diff --git a/crypto/asn1/a_int.c b/crypto/asn1/a_int.c index 92c58b34184..6774ba627c3 100644 --- a/crypto/asn1/a_int.c +++ b/crypto/asn1/a_int.c @@ -308,8 +308,10 @@ ASN1_INTEGER *ossl_c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, c2i_ibuf(ret->data, &neg, *pp, len); - if (neg) + if (neg != 0) ret->type |= V_ASN1_NEG; + else + ret->type &= ~V_ASN1_NEG; *pp += len; if (a != NULL) @@ -317,7 +319,7 @@ ASN1_INTEGER *ossl_c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, return ret; err: ERR_raise(ERR_LIB_ASN1, ERR_R_MALLOC_FAILURE); - if ((a == NULL) || (*a != ret)) + if (a == NULL || *a != ret) ASN1_INTEGER_free(ret); return NULL; }