forked from wolfSSL/wolfssl
Merge pull request #371 from cconlon/sniffer-fix
Extra cleanup in sniffer.c with ForceZero
This commit is contained in:
@@ -1082,6 +1082,7 @@ static int LoadKeyFile(byte** keyBuf, word32* keyBufSz,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ForceZero(loadBuf, (word32)fileSz);
|
||||||
free(loadBuf);
|
free(loadBuf);
|
||||||
|
|
||||||
*keyBuf = saveBuf;
|
*keyBuf = saveBuf;
|
||||||
@@ -3093,6 +3094,7 @@ doPart:
|
|||||||
* wants to null terminate plaintext */
|
* wants to null terminate plaintext */
|
||||||
tmpData = (byte*)realloc(*data, decoded + ret + 1);
|
tmpData = (byte*)realloc(*data, decoded + ret + 1);
|
||||||
if (tmpData == NULL) {
|
if (tmpData == NULL) {
|
||||||
|
ForceZero(*data, decoded);
|
||||||
free(*data);
|
free(*data);
|
||||||
*data = NULL;
|
*data = NULL;
|
||||||
SetError(MEMORY_STR, error, session,
|
SetError(MEMORY_STR, error, session,
|
||||||
@@ -3243,10 +3245,23 @@ int ssl_DecodePacket(const byte* packet, int length, byte** data, char* error)
|
|||||||
/* Deallocator for the decoded data buffer. */
|
/* Deallocator for the decoded data buffer. */
|
||||||
/* returns 0 on success, -1 on error */
|
/* returns 0 on success, -1 on error */
|
||||||
int ssl_FreeDecodeBuffer(byte** data, char* error)
|
int ssl_FreeDecodeBuffer(byte** data, char* error)
|
||||||
|
{
|
||||||
|
return ssl_FreeZeroDecodeBuffer(data, 0, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Deallocator for the decoded data buffer, zeros out buffer. */
|
||||||
|
/* returns 0 on success, -1 on error */
|
||||||
|
int ssl_FreeZeroDecodeBuffer(byte** data, int sz, char* error)
|
||||||
{
|
{
|
||||||
(void)error;
|
(void)error;
|
||||||
|
|
||||||
|
if (sz < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (data != NULL) {
|
if (data != NULL) {
|
||||||
|
ForceZero(*data, (word32)sz);
|
||||||
free(*data);
|
free(*data);
|
||||||
*data = NULL;
|
*data = NULL;
|
||||||
}
|
}
|
||||||
|
@@ -313,8 +313,8 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
data[ret] = 0;
|
data[ret] = 0;
|
||||||
printf("SSL App Data(%d:%d):%s\n", packetNumber, ret, data);
|
printf("SSL App Data(%d:%d):%s\n", packetNumber, ret, data);
|
||||||
ssl_FreeDecodeBuffer(&data, err);
|
ssl_FreeZeroDecodeBuffer(&data, ret, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (saveFile)
|
else if (saveFile)
|
||||||
|
@@ -62,6 +62,10 @@ SSL_SNIFFER_API int ssl_DecodePacket(const unsigned char* packet, int length,
|
|||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
SSL_SNIFFER_API int ssl_FreeDecodeBuffer(unsigned char** data, char* error);
|
SSL_SNIFFER_API int ssl_FreeDecodeBuffer(unsigned char** data, char* error);
|
||||||
|
|
||||||
|
WOLFSSL_API
|
||||||
|
SSL_SNIFFER_API int ssl_FreeZeroDecodeBuffer(unsigned char** data, int sz,
|
||||||
|
char* error);
|
||||||
|
|
||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
SSL_SNIFFER_API int ssl_Trace(const char* traceFile, char* error);
|
SSL_SNIFFER_API int ssl_Trace(const char* traceFile, char* error);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user