From 5713ee5fc3236fd940cea707cd8707d7ec5fa665 Mon Sep 17 00:00:00 2001 From: Jeremy Ellington Date: Wed, 28 Jul 2004 15:01:00 +0000 Subject: [PATCH] Fixed memory leak. Added assert. --- ipmitool/src/plugins/lanplus/lanplus_crypt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ipmitool/src/plugins/lanplus/lanplus_crypt.c b/ipmitool/src/plugins/lanplus/lanplus_crypt.c index 1f729e4..95a9cb5 100644 --- a/ipmitool/src/plugins/lanplus/lanplus_crypt.c +++ b/ipmitool/src/plugins/lanplus/lanplus_crypt.c @@ -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; }