Snort mailing list archives

Re: [SNORT-DEVEL] modification to switch()/case in snprintf.c for NetVI


From: "Russ Combs (rucombs)" <rucombs () cisco com>
Date: Mon, 14 Apr 2014 12:40:55 +0000

Bill, thanks for the patch.  We will take a look at is as soon as we finish editing this backlog of packets.

Russ

________________________________
From: Bill Parker [wp02855 () gmail com]
Sent: Sunday, April 13, 2014 3:27 PM
To: snort-devel () lists sourceforge net
Subject: [Snort-devel] [SNORT-DEVEL] modification to switch()/case in snprintf.c for NetVI

Hello All,

    In reviewing some code in NetVI, directory 'src', file 'snprintf.c'
I found a rather lengthy switch()/case workup consisting of the following:

                    case '1':
                    case '2':
                    case '3':
                    case '4':
                    case '5':
                    case '6':
                    case '7':
                    case '8':
                    case '9':

Which could be written as:

                    case '1' ... '9':

since ASCII values for '1' thru '9' are in order in the ASCII
table.  The patch file which modifies this is below:

--- snprintf.c.orig     2014-04-10 04:39:57.132977816 -0700
+++ snprintf.c  2014-04-10 04:40:45.194086136 -0700
@@ -174,15 +174,7 @@
                     case '-': ljust = 1; goto nextch;
                     case '0': /* set zero padding if len not set */
                         if(len==0 && !pointflag) zpad = '0';
-                    case '1':
-                    case '2':
-                    case '3':
-                    case '4':
-                    case '5':
-                    case '6':
-                    case '7':
-                    case '8':
-                    case '9':
+                    case '1' ... '9':
                         if(pointflag)
                             maxwidth = maxwidth*10 + ch - '0';
                         else

Would this be of any use in NetVI and/or Snort/DAQ?

Bill Parker (wp02855 at gmail dot com)
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
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: