Fixed memory leak. Added assert.

This commit is contained in:
Jeremy Ellington 2004-07-28 15:01:00 +00:00
parent 285a4d9ce2
commit 5713ee5fc3

View File

@ -666,10 +666,13 @@ int lanplus_encrypt_payload(unsigned char crypt_alg,
/* Currently, we only support AES */
assert(crypt_alg == IPMI_CRYPT_AES_CBC_128);
assert(input_length <= 255);
/*
* The input to the AES encryption algorithm has to be a multiple of the block
* size (16 bytes). The extra byte we are adding is the pad length byte.
* The input to the AES encryption algorithm has to be a multiple of the
* block size (16 bytes). The extra byte we are adding is the pad length
* byte.
*/
mod = (input_length + 1) % IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE;
if (mod)
@ -709,6 +712,8 @@ int lanplus_encrypt_payload(unsigned char crypt_alg,
IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE + /* IV */
bytes_encrypted;
free(padded_input);
return 0;
}