From ab68f38236e8bc89180bc1a0c542b50e811ee1b4 Mon Sep 17 00:00:00 2001 From: toddouska Date: Fri, 23 Oct 2015 16:38:59 -0700 Subject: [PATCH] have allocate extra byte in case user wants to null terminate returned plaintext --- src/sniffer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sniffer.c b/src/sniffer.c index cd33c738f..e1a57ec1f 100644 --- a/src/sniffer.c +++ b/src/sniffer.c @@ -3078,7 +3078,9 @@ doPart: TraceGotData(ret); if (ret) { /* may be blank message */ byte* tmpData; /* don't leak on realloc free */ - tmpData = (byte*)realloc(*data, decoded + ret); + /* add an extra byte at end of allocation in case user + * wants to null terminate plaintext */ + tmpData = (byte*)realloc(*data, decoded + ret + 1); if (tmpData == NULL) { free(*data); *data = NULL;