mirror of
https://github.com/openssl/openssl.git
synced 2024-11-21 01:15:20 +08:00
move check to avoid memory leak.
This commit is contained in:
parent
ee8aa8217a
commit
8ca2ae775d
@ -102,6 +102,14 @@ int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
|
||||
return (-1);
|
||||
}
|
||||
|
||||
lzero = num - flen;
|
||||
if (lzero < 0)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_OAEP_DECODING_ERROR);
|
||||
return (-1);
|
||||
}
|
||||
maskeddb = from - lzero + SHA_DIGEST_LENGTH;
|
||||
|
||||
dblen = num - SHA_DIGEST_LENGTH;
|
||||
db = OPENSSL_malloc(dblen);
|
||||
if (db == NULL)
|
||||
@ -110,14 +118,6 @@ int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
|
||||
return (-1);
|
||||
}
|
||||
|
||||
lzero = num - flen;
|
||||
if (lzero < 0)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_OAEP_DECODING_ERROR);
|
||||
return (-1);
|
||||
}
|
||||
maskeddb = from - lzero + SHA_DIGEST_LENGTH;
|
||||
|
||||
MGF1(seed, SHA_DIGEST_LENGTH, maskeddb, dblen);
|
||||
for (i = lzero; i < SHA_DIGEST_LENGTH; i++)
|
||||
seed[i] ^= from[i - lzero];
|
||||
|
Loading…
Reference in New Issue
Block a user