aboutsummaryrefslogtreecommitdiff
path: root/example/ndpiReader.c
diff options
context:
space:
mode:
authorysk <shaokunyang@163.com>2020-07-10 17:49:35 +0800
committerysk <shaokunyang@163.com>2020-07-10 17:49:35 +0800
commit35f1c362b9c005a1094f19cd4cdf5039e5e887d5 (patch)
tree83dacce992987d2bd27bc8d174a9ac8b2424e699 /example/ndpiReader.c
parent12abcd516b468f6e0070308fa57052b93aa3a3ca (diff)
add improved boundary check and check malloc return is NULL
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r--example/ndpiReader.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 25535e6b3..413dee95d 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -2943,6 +2943,9 @@ static void ndpi_process_packet(u_char *args,
/* allocate an exact size buffer to check overflows */
uint8_t *packet_checked = malloc(header->caplen);
+ if(packet_checked == NULL){
+ return ;
+ }
memcpy(packet_checked, packet, header->caplen);
p = ndpi_workflow_process_packet(ndpi_thread_info[thread_id].workflow, header, packet_checked, csv_fp);
@@ -3047,7 +3050,10 @@ static void ndpi_process_packet(u_char *args,
Leave the free as last statement to avoid crashes when ndpi_detection_giveup()
is called above by printResults()
*/
- free(packet_checked);
+ if(packet_checked){
+ free(packet_checked);
+ packet_checked = NULL;
+ }
}
/**