Add function ssl_FreeDecodeBuffer() to release the sniffer allocated data buffer and reset the pointer.

This commit is contained in:
John Safranek 2015-10-26 12:01:21 -07:00
parent b05332c417
commit a42308e28a
3 changed files with 19 additions and 2 deletions

View File

@ -3229,6 +3229,21 @@ int ssl_DecodePacket(const byte* packet, int length, byte** data, char* error)
}
/* Deallocator for the decoded data buffer. */
/* returns 0 on success, -1 on error */
int ssl_FreeDecodeBuffer(byte** data, char* error)
{
(void)error;
if (data != NULL) {
free(*data);
*data = NULL;
}
return 0;
}
/* Enables (if traceFile)/ Disables debug tracing */
/* returns 0 on success, -1 on error */
int ssl_Trace(const char* traceFile, char* error)

View File

@ -313,8 +313,7 @@ int main(int argc, char** argv)
if (ret > 0) {
data[ret] = 0;
printf("SSL App Data(%d:%d):%s\n", packetNumber, ret, data);
free(data);
data = NULL;
ssl_FreeDecodeBuffer(&data, err);
}
}
else if (saveFile)

View File

@ -58,6 +58,9 @@ WOLFSSL_API
SSL_SNIFFER_API int ssl_DecodePacket(const unsigned char* packet, int length,
unsigned char** data, char* error);
WOLFSSL_API
SSL_SNIFFER_API int ssl_FreeDecodeBuffer(unsigned char** data, char* error);
WOLFSSL_API
SSL_SNIFFER_API int ssl_Trace(const char* traceFile, char* error);