Snort mailing list archives

Re: Inconsistent use of memset() in snort<nnnn>/src/sfutil/acsmx2.c & ascmx.c


From: "Cynthia Leonard (cyleonar)" <cyleonar () cisco com>
Date: Tue, 26 May 2015 06:49:31 +0000

Thanks Bill, we check this out and will try to include it .

Regards
Cynthia


From: Bill Parker [mailto:wp02855 () gmail com]
Sent: Monday, May 25, 2015 11:35 PM
To: snort-devel () lists sourceforge net
Subject: [Snort-devel] Inconsistent use of memset() in snort<nnnn>/src/sfutil/acsmx2.c & ascmx.c

Hello All,

    In doing some review, I found an instance of memset() being
called where the sizeof() operator references the 'type' rather
than the actual variable, as an example:

In Create new AC_STATE machine:

ACSM_STRUCT2 * p;

but the memset a few lines later does this:

memset (p, 0, sizeof (ACSM_STRUCT2));

would it not be more proper to code it like this:

memset (p, 0, sizeof (*p));

The patch file for this is below:

--- acsmx2.c.orig       2015-05-21 19:07:06.286928174 -0700
+++ acsmx2.c    2015-05-21 19:09:26.476745579 -0700
@@ -1661,7 +1661,7 @@

   if (p)
   {
-    memset (p, 0, sizeof (ACSM_STRUCT2));
+    memset (p, 0, sizeof (*p));

     /* Some defaults */
     p->acsmFSA               = FSA_DFA;

I found the same issue in file 'acsmx.c' as well:

--- acsmx.c.orig        2015-05-21 19:19:46.051490343 -0700
+++ acsmx.c     2015-05-21 19:20:21.479993124 -0700
@@ -460,7 +460,7 @@
   MEMASSERT (p, "acsmNew");
   if (p)
   {
-    memset (p, 0, sizeof (ACSM_STRUCT));
+    memset (p, 0, sizeof (*p));
     p->userfree              = userfree;
     p->optiontreefree        = optiontreefree;
     p->neg_list_free         = neg_list_free;

Bill Parker (wp02855 at gmail dot com)
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Snort-devel mailing list
Snort-devel () lists sourceforge net
https://lists.sourceforge.net/lists/listinfo/snort-devel
Archive:
http://sourceforge.net/mailarchive/forum.php?forum_name=snort-devel

Please visit http://blog.snort.org for the latest news about Snort!

Current thread: