Fix a possible integer overflow in long_c2i
Credit to OSS-Fuzz for finding this.
@@ -149,6 +149,10 @@ static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
utmp |= cont[i];
}
ltmp = (long)utmp;
+ if (ltmp < 0) {
+ ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG);
+ return 0;
+ }
if (neg) {
ltmp = -ltmp;
ltmp--;
