forked from wolfSSL/wolfssl
fix mmCAU classic XFREE on aligned ptr
This commit is contained in:
@ -1920,6 +1920,7 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
|||||||
byte* rk = (byte*)aes->key;
|
byte* rk = (byte*)aes->key;
|
||||||
byte* tmpKey = (byte*)userKey;
|
byte* tmpKey = (byte*)userKey;
|
||||||
int tmpKeyDynamic = 0;
|
int tmpKeyDynamic = 0;
|
||||||
|
word32 alignOffset = 0;
|
||||||
|
|
||||||
(void)dir;
|
(void)dir;
|
||||||
|
|
||||||
@ -1943,8 +1944,9 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
|||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return MEMORY_E;
|
return MEMORY_E;
|
||||||
}
|
}
|
||||||
tmpKey = tmp + (WOLFSSL_MMCAU_ALIGNMENT -
|
alignOffset = WOLFSSL_MMCAU_ALIGNMENT -
|
||||||
((wolfssl_word)tmp % WOLFSSL_MMCAU_ALIGNMENT));
|
((wolfssl_word)tmp % WOLFSSL_MMCAU_ALIGNMENT);
|
||||||
|
tmpKey = tmp + alignOffset;
|
||||||
XMEMCPY(tmpKey, userKey, keylen);
|
XMEMCPY(tmpKey, userKey, keylen);
|
||||||
tmpKeyDynamic = 1;
|
tmpKeyDynamic = 1;
|
||||||
#else
|
#else
|
||||||
@ -1967,7 +1969,7 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tmpKeyDynamic == 1) {
|
if (tmpKeyDynamic == 1) {
|
||||||
XFREE(tmpKey, aes->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(tmpKey - alignOffset, aes->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user