From 2f324e770f0fd58065b9e80d878fd3536897ea81 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Tue, 28 Mar 2017 08:21:55 -0400 Subject: randpkt_core: Fix a handful of warnings 1. randpkt_core.c(559): warning C6262: Function uses '65596' bytes of stack: exceeds /analyze:stacksize '16384'. Consider moving some data to heap. 2. randpkt_core.c(615): warning C6386: Buffer overrun while writing to 'buffer': the writable size is '65536' bytes, but '-1' bytes might be written. Change-Id: I0f3bcd19b49d6c8cde0d2ad9f745b14f5462a708 Reviewed-on: https://code.wireshark.org/review/20763 Petri-Dish: Michael Mann Reviewed-by: Dario Lombardo Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- randpkt_core/randpkt_core.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'randpkt_core/randpkt_core.c') diff --git a/randpkt_core/randpkt_core.c b/randpkt_core/randpkt_core.c index 3233d625a9..06f9ab910f 100644 --- a/randpkt_core/randpkt_core.c +++ b/randpkt_core/randpkt_core.c @@ -558,25 +558,22 @@ randpkt_example* randpkt_find_example(int type) void randpkt_loop(randpkt_example* example, guint64 produce_count) { - guint i; - int j; + guint i, j; int err; - int len_random; - int len_this_pkt; + guint len_random; + guint len_this_pkt; gchar* err_info; union wtap_pseudo_header* ps_header; - guint8 buffer[65536]; + guint8* buffer; struct wtap_pkthdr* pkthdr; pkthdr = g_new0(struct wtap_pkthdr, 1); + buffer = (guint8*)g_malloc0(65536); pkthdr->rec_type = REC_TYPE_PACKET; pkthdr->presence_flags = WTAP_HAS_TS; pkthdr->pkt_encap = example->sample_wtap_encap; - memset(pkthdr, 0, sizeof(struct wtap_pkthdr)); - memset(buffer, 0, sizeof(buffer)); - ps_header = &pkthdr->pseudo_header; /* Load the sample pseudoheader into our pseudoheader buffer */ @@ -678,6 +675,7 @@ void randpkt_loop(randpkt_example* example, guint64 produce_count) } g_free(pkthdr); + g_free(buffer); } gboolean randpkt_example_close(randpkt_example* example) -- cgit v1.2.1