Skip to content

Commit

Permalink
Close #351: a1int::getLong() doesn't handle all error cases
Browse files Browse the repository at this point in the history
Check for LONG_MAX and LONG_MIN and throw an error if the returned value
is too big.
  • Loading branch information
chris2511 committed Aug 30, 2024
1 parent 6777f7c commit 1684593
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/asn1int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ const ASN1_INTEGER *a1int::get0() const

long a1int::getLong() const
{
long l = ASN1_INTEGER_get(get0());
openssl_error();
return l;
int64_t value;
int r = ASN1_INTEGER_get_int64(&value,get0());
if (r == 0 || value > LONG_MAX || value < LONG_MIN)
throw errorEx(QString("ASN1 Integer: Failed to convert %1 to long").arg(toDec()));
return (long)value;
}

a1int &a1int::operator ++ (void)
Expand Down

0 comments on commit 1684593

Please sign in to comment.