mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 02:37:28 +02:00
Prevent forcezero from running on freed memory
This commit is contained in:
@ -1197,6 +1197,7 @@ static int LoadKeyFile(byte** keyBuf, word32* keyBufSz,
|
||||
if (saveBufSz < 0) {
|
||||
saveBufSz = 0;
|
||||
free(saveBuf);
|
||||
saveBuf = NULL;
|
||||
}
|
||||
else
|
||||
ret = 0;
|
||||
@ -1205,8 +1206,10 @@ static int LoadKeyFile(byte** keyBuf, word32* keyBufSz,
|
||||
ForceZero(loadBuf, (word32)fileSz);
|
||||
free(loadBuf);
|
||||
|
||||
*keyBuf = saveBuf;
|
||||
*keyBufSz = (word32)saveBufSz;
|
||||
if (saveBuf) {
|
||||
*keyBuf = saveBuf;
|
||||
*keyBufSz = (word32)saveBufSz;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*keyBuf = loadBuf;
|
||||
|
Reference in New Issue
Block a user