Fixing a bug on platforms where size_t is unsigned.

This commit is contained in:
Tobias Brunner
2010-03-03 17:35:19 +01:00
parent 465ccdc8cf
commit ea2f2c4b90
@@ -480,15 +480,15 @@ static status_t decrypt(private_encryption_payload_t *this)
/* add one byte to the padding length, since the padding_length field is /* add one byte to the padding length, since the padding_length field is
* not included */ * not included */
padding_length++; padding_length++;
this->decrypted.len -= padding_length;
/* check size again */ /* check size again */
if (padding_length > concatenated.len || this->decrypted.len < 0) if (padding_length > concatenated.len || padding_length > this->decrypted.len)
{ {
DBG1(DBG_ENC, "decryption failed, invalid padding length found. Invalid key?"); DBG1(DBG_ENC, "decryption failed, invalid padding length found. Invalid key?");
/* decryption failed :-/ */ /* decryption failed :-/ */
return FAILED; return FAILED;
} }
this->decrypted.len -= padding_length;
/* free padding */ /* free padding */
this->decrypted.ptr = realloc(this->decrypted.ptr, this->decrypted.len); this->decrypted.ptr = realloc(this->decrypted.ptr, this->decrypted.len);