[prev in list] [next in list] [prev in thread] [next in thread] 

List:       snort-devel
Subject:    Re: [Snort-devel] Replace calls index() <deprecated> with strchr() in Snort 2.9.5
From:       Joel Esler <jesler () sourcefire ! com>
Date:       2013-07-19 19:43:33
Message-ID: 55F2ED60-4A0B-4F70-94D5-8E883A64FF60 () sourcefire ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Thanks Bill, we’ll take a look.

--
Joel Esler
Senior Research Engineer, VRT
OpenSource Community Manager
Sourcefire

On Jul 19, 2013, at 3:08 PM, Bill Parker <wp02855@gmail.com> wrote:

> Hello All,
> 
> 	In reviewing various files in Snort-2.9.5, I found a number
> of instances where index() <deprecated> was used, and the patch
> files below replace calls to index() with strchr() <ANSI/ISO>.
> 
> In directory 'snort-2.9.5/src/detection-plugins', file 
> 'sp_ip_tos_check.c', the following patch file replaces
> calls to index() with strchr():
> 
> --- sp_ip_tos_check.c.orig      2013-07-18 12:27:51.397883953 -0700
> +++ sp_ip_tos_check.c   2013-07-18 12:28:32.473881887 -0700
> @@ -200,7 +200,7 @@
> start = &data[0];
> }
> 
> -    if(index(start, (int) 'x') == NULL && index(start, (int)'X') == NULL)
> +    if(strchr(start, (int) 'x') == NULL && strchr(start, (int)'X') == NULL)
> {
> ds_ptr->ip_tos = (uint8_t)SnortStrtoulRange(start, &endTok, 10, 0, UINT8_MAX);
> if ((endTok == start) || (*endTok != '\0'))
> @@ -212,10 +212,10 @@
> else
> {
> /* hex? */
> -        start = index(data,(int)'x');
> +        start = strchr(data,(int)'x');
> if(!start)
> {
> -            start = index(data,(int)'X');
> +            start = strchr(data,(int)'X');
> }
> if (start)
> {
> 		 
> In directory 'snort-2.9.5/src/detection-plugins', file 
> 'sp_pattern_match.c', the following patch file replaces
> calls to index() with strchr() <this also contains a
> previous patch for converting bzero() calls to memset()>:
> 
> --- sp_pattern_match.c.orig     2013-07-18 08:43:44.369888130 -0700
> +++ sp_pattern_match.c  2013-07-18 12:33:24.026883058 -0700
> @@ -1324,21 +1324,21 @@
> char *quote_one = NULL, *quote_two = NULL;
> char *comma = NULL;
> 
> -    quote_one = index(data, '"');
> +    quote_one = strchr(data, '"');
> if (quote_one)
> {
> -        quote_two = index(quote_one+1, '"');
> +        quote_two = strchr(quote_one+1, '"');
> while ( quote_two && quote_two[-1] == '\\' )
> -            quote_two = index(quote_two+1, '"');
> +            quote_two = strchr(quote_two+1, '"');
> }
> 
> if (quote_one && quote_two)
> {
> -        comma = index(quote_two, ',');
> +        comma = strchr(quote_two, ',');
> }
> else if (!quote_one)
> {
> -        comma = index(data, ',');
> +        comma = strchr(data, ',');
> }
> 
> if (comma)
> @@ -1471,7 +1471,7 @@
> PatternMatchData *ds_idx;
> 
> /* clear out the temp buffer */
> -    bzero(tmp_buf, MAX_PATTERN_SIZE);
> +    memset(tmp_buf, '\0', MAX_PATTERN_SIZE);
> 
> if (rule == NULL)
> ParseError("ParsePattern Got Null enclosed in quotation marks (\")!");
> @@ -1486,7 +1486,7 @@
> }
> 
> /* find the start of the data */
> -    start_ptr = index(rule, '"');
> +    start_ptr = strchr(rule, '"');
> 
> if (start_ptr != rule)
> ParseError("Content data needs to be enclosed in quotation marks (\")!");
> @@ -1530,8 +1530,7 @@
> dummy_end = (dummy_idx + size);
> 
> /* why is this buffer so small? */
> -    bzero(hex_buf, 3);
> -    memset(hex_buf, '0', 2);
> +    memset(hex_buf, '\0', 3);
> 
> /* BEGIN BAD JUJU..... */
> while(idx < end_ptr)
> @@ -1640,8 +1639,7 @@
> strtol(hex_buf, (char **) NULL, 16)&0xFF;
> 
> dummy_size++;
> -                                bzero(hex_buf, 3);
> -                                memset(hex_buf, '0', 2);
> +                                memset(hex_buf, '\0', 3);
> }
> else
> {
> @@ -2486,7 +2484,7 @@
> data++;
> 
> /* grab everything between the starting " and the end one */
> -    sptr = index(data, '"');
> +    sptr = strchr(data, '"');
> eptr = strrchr(data, '"');
> 
> if(sptr != NULL && eptr != NULL)
> @@ -2545,8 +2543,8 @@
> }
> 
> /* clear the line and rule buffers */
> -    bzero((char *) buf, STD_BUF);
> -    bzero((char *) rule_buf, STD_BUF);
> +    memset((char *) buf, '\0', STD_BUF);
> +    memset((char *) rule_buf, '\0', STD_BUF);
> frazes_count = 0;
> 
> /* loop thru each list_file line and content to the rule */
> 	 
> In directory 'snort-2.9.5/src/detection-plugins', file 
> 'sp_tcp_win_check.c', the following patch file replaces
> calls to index() with strchr():
> 
> --- sp_tcp_win_check.c.orig     2013-07-18 12:36:11.167880131 -0700
> +++ sp_tcp_win_check.c  2013-07-18 12:36:49.028881611 -0700
> @@ -205,7 +205,7 @@
> start = &data[0];
> }
> 
> -    if(index(start, (int) 'x') == NULL && index(start, (int)'X') == NULL)
> +    if(strchr(start, (int) 'x') == NULL && strchr(start, (int)'X') == NULL)
> {
> win_size = SnortStrtolRange(start, &endTok, 10, 0, UINT16_MAX);
> if ((endTok == start) || (*endTok != '\0'))
> @@ -217,10 +217,10 @@
> else
> {
> /* hex? */
> -        start = index(data,(int)'x');
> +        start = strchr(data,(int)'x');
> if(!start)
> {
> -            start = index(data,(int)'X');
> +            start = strchr(data,(int)'X');
> }
> if (start)
> {
> 
> In directory 'snort-2.9.5/src/detection-plugins', file 
> 'sp_replace.c', the following patch file replaces calls
> to index() with strchr() <this also contains a previous
> patch for converting bzero() calls to memset()>:
> 		 
> --- sp_replace.c.orig   2013-07-18 08:48:41.818893728 -0700
> +++ sp_replace.c        2013-07-18 12:38:44.570878841 -0700
> @@ -111,7 +111,7 @@
> file_name, file_line);
> }
> /* clear out the temp buffer */
> -    bzero(tmp_buf, MAX_PATTERN_SIZE);
> +    memset(tmp_buf, '\0', MAX_PATTERN_SIZE);
> 
> while(isspace((int)*rule))
> rule++;
> @@ -122,7 +122,7 @@
> }
> 
> /* find the start of the data */
> -    start_ptr = index(rule, '"');
> +    start_ptr = strchr(rule, '"');
> 
> if(start_ptr == NULL)
> {
> @@ -163,8 +163,7 @@
> dummy_end = (dummy_idx + size);
> 
> /* why is this buffer so small? */
> -    bzero(hex_buf, 3);
> -    memset(hex_buf, '0', 2);
> +    memset(hex_buf, '\0', 3);
> 
> /* BEGIN BAD JUJU..... */
> while(idx < end_ptr)
> @@ -269,8 +268,7 @@
> strtol(hex_buf, (char **) NULL, 16)&0xFF;
> 
> dummy_size++;
> -                                bzero(hex_buf, 3);
> -                                memset(hex_buf, '0', 2);
> +                                memset(hex_buf, '\0', 3);
> }
> else
> {
> 							 
> 
> In directory 'snort-2.9.5/src/dynamic-preprocessors/sdf',
> file  'sdf_pattern_match.c', the following patch file
> replaces calls to index() with strchr():
> 							 
> --- sdf_pattern_match.c.orig    2013-07-18 12:40:51.368879507 -0700
> +++ sdf_pattern_match.c 2013-07-18 12:41:17.518883291 -0700
> @@ -82,7 +82,7 @@
> return;
> 
> /* Locate first '{' */
> -    bracket_index = index(*pii, '{');
> +    bracket_index = strchr(*pii, '{');
> 
> /* Brackets at the beginning have nothing to modify. */
> if (bracket_index == *pii)
> @@ -97,7 +97,7 @@
> /* Ignore escaped brackets */
> if ((bracket_index > *pii) && (*(bracket_index-1) == '\\'))
> {
> -            bracket_index = index(bracket_index+1, '{');
> +            bracket_index = strchr(bracket_index+1, '{');
> continue;
> }
> 
> @@ -133,7 +133,7 @@
> num_brackets++;
> 
> /* Next bracket */
> -        bracket_index = index(bracket_index+1, '{');
> +        bracket_index = strchr(bracket_index+1, '{');
> }
> 
> /* By this point, the brackets all match up. */
> 	 
> 
> In directory 'snort-2.9.5/src/dynamic-preprocessors/ftptelnet',
> file 'pp_ftp.c', the following patch file replaces calls to
> index() with strchr():
> 
> --- pp_ftp.c.orig       2013-07-18 12:44:46.451880548 -0700
> +++ pp_ftp.c    2013-07-18 12:45:04.336881624 -0700
> @@ -358,7 +358,7 @@
> strncpy(buf, tok, len);
> buf[len] = '\0';
> }
> -    s = index(buf, delim);
> +    s = strchr(buf, delim);
> 
> if ( s ) *s = '\0';
> else *buf = '\0';
> @@ -414,7 +414,7 @@
> break;
> }
> /* advance to next field */
> -        tok = index(tok, delim);
> +        tok = strchr(tok, delim);
> field++;
> }
> 
> In directory 'snort-2.9.5/src/dynamic-preprocessors/ftptelnet',
> file 'snort_ftptelnet.c', the following patch file replaces
> calls to index() with strchr():
> 
> --- snort_ftptelnet.c.orig      2013-07-18 12:45:48.489881388 -0700
> +++ snort_ftptelnet.c   2013-07-18 12:46:03.974880469 -0700
> @@ -1915,7 +1915,7 @@
> }
> else if ( *fmt == *F_LITERAL )
> {
> -        char* end = index(++fmt, *F_LITERAL);
> +        char* end = strchr(++fmt, *F_LITERAL);
> int len = end ? end - fmt : 0;
> 
> if ( len < 1 )
> 		 
> A 'make' and 'make install' results in a clean compile and
> installation of the above patch files for Snort-2.9.5
> 
> Here is a listing of the files in the archive:
> 
> Archive:  index-patches.zip
> Length      Date    Time    Name
> ---------  ---------- -----   ----
> 775  07-18-2013 12:32   sp_ip_tos_check.c.patch
> 2597  07-18-2013 12:35   sp_pattern_match.c.patch
> 762  07-18-2013 12:38   sp_tcp_win_check.c.patch
> 900  07-18-2013 12:43   sdf_pattern_match.c.patch
> 484  07-18-2013 12:47   pp_ftp.c.patch
> 354  07-18-2013 12:46   snort_ftptelnet.c.patch
> 1003  07-18-2013 08:50   sp_replace.c.patch
> ---------                     -------
> 6875                     7 files
> 	 
> I am attaching the patch files (as a zip archive) to
> this e-mail
> 
> Bill Parker (wp02855 at gmail dot com)
> <index-patches.zip>------------------------------------------------------------------------------
>  See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk_______________________________________________
>  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!


[Attachment #5 (unknown)]

<html><head><meta http-equiv="Content-Type" content="text/html \
charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: \
space; -webkit-line-break: after-white-space;">Thanks Bill, we’ll take a \
look.<div><br></div><div><span style="font-size: 12px; font-family: 'Lucida \
Grande';">--</span><br><span style="font-size: 12px; font-family: 'Lucida \
Grande';"><b>Joel Esler</b></span><br><span style="font-size: 12px; font-family: \
'Lucida Grande';">Senior Research Engineer, VRT</span><br><span style="font-size: \
12px; font-family: 'Lucida Grande';">OpenSource Community Manager</span><br><span \
style="font-size: 12px; font-family: 'Lucida \
Grande';">Sourcefire</span></div><div><font face="Lucida Grande"><span \
style="font-size: 12px;"><br></span></font><div><div>On Jul 19, 2013, at 3:08 PM, \
Bill Parker &lt;<a href="mailto:wp02855@gmail.com">wp02855@gmail.com</a>&gt; \
wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div \
style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant: \
normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: \
auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; \
widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div \
dir="ltr"><div>Hello All,<br></div><div><br></div><div><span class="" \
style="white-space: pre;">	</span>In reviewing various files in Snort-2.9.5, I found \
a number</div><div>of instances where index() &lt;deprecated&gt; was used, and the \
patch</div><div>files below replace calls to index() with strchr() \
&lt;ANSI/ISO&gt;.</div><div><br></div><div>In directory \
'snort-2.9.5/src/detection-plugins', file&nbsp;</div><div>'sp_ip_tos_check.c', the \
following patch file replaces</div><div>calls to index() with \
strchr():</div><div><br></div><div>--- sp_ip_tos_check.c.orig &nbsp; &nbsp; \
&nbsp;2013-07-18 12:27:51.397883953 -0700</div><div>+++ sp_ip_tos_check.c &nbsp; \
2013-07-18 12:28:32.473881887 -0700</div><div>@@ -200,7 +200,7 @@</div><div>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp;start = &amp;data[0];</div><div>&nbsp; &nbsp; \
&nbsp;}</div><div>&nbsp;</div><div>- &nbsp; &nbsp;if(index(start, (int) 'x') == NULL \
&amp;&amp; index(start, (int)'X') == NULL)</div><div>+ &nbsp; &nbsp;if(strchr(start, \
(int) 'x') == NULL &amp;&amp; strchr(start, (int)'X') == NULL)</div><div>&nbsp; \
&nbsp; &nbsp;{</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ds_ptr-&gt;ip_tos = \
(uint8_t)SnortStrtoulRange(start, &amp;endTok, 10, 0, UINT8_MAX);</div><div>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp;if ((endTok == start) || (*endTok != '\0'))</div><div>@@ \
-212,10 +212,10 @@</div><div>&nbsp; &nbsp; &nbsp;else</div><div>&nbsp; &nbsp; \
&nbsp;{</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* hex? */</div><div>- &nbsp; \
&nbsp; &nbsp; &nbsp;start = index(data,(int)'x');</div><div>+ &nbsp; &nbsp; &nbsp; \
&nbsp;start = strchr(data,(int)'x');</div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;if(!start)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>- &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;start = index(data,(int)'X');</div><div>+ &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;start = strchr(data,(int)'X');</div><div>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if \
(start)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div><span class="" \
style="white-space: pre;">		</span>&nbsp;</div><div>In directory \
'snort-2.9.5/src/detection-plugins', file&nbsp;</div><div>'sp_pattern_match.c', the \
following patch file replaces</div><div>calls to index() with strchr() &lt;this also \
contains a</div><div>previous patch for converting bzero() calls to \
memset()&gt;:</div><div><br></div><div>--- sp_pattern_match.c.orig &nbsp; &nbsp; \
2013-07-18 08:43:44.369888130 -0700</div><div>+++ sp_pattern_match.c &nbsp;2013-07-18 \
12:33:24.026883058 -0700</div><div>@@ -1324,21 +1324,21 @@</div><div>&nbsp; &nbsp; \
&nbsp;char *quote_one = NULL, *quote_two = NULL;</div><div>&nbsp; &nbsp; &nbsp;char \
*comma = NULL;</div><div>&nbsp;</div><div>- &nbsp; &nbsp;quote_one = index(data, \
'"');</div><div>+ &nbsp; &nbsp;quote_one = strchr(data, '"');</div><div>&nbsp; &nbsp; \
&nbsp;if (quote_one)</div><div>&nbsp; &nbsp; &nbsp;{</div><div>- &nbsp; &nbsp; &nbsp; \
&nbsp;quote_two = index(quote_one+1, '"');</div><div>+ &nbsp; &nbsp; &nbsp; \
&nbsp;quote_two = strchr(quote_one+1, '"');</div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;while ( quote_two &amp;&amp; quote_two[-1] == '\\' )</div><div>- &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp;quote_two = index(quote_two+1, '"');</div><div>+ &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;quote_two = strchr(quote_two+1, \
'"');</div><div>&nbsp; &nbsp; &nbsp;}</div><div>&nbsp;</div><div>&nbsp; &nbsp; \
&nbsp;if (quote_one &amp;&amp; quote_two)</div><div>&nbsp; &nbsp; &nbsp;{</div><div>- \
&nbsp; &nbsp; &nbsp; &nbsp;comma = index(quote_two, ',');</div><div>+ &nbsp; &nbsp; \
&nbsp; &nbsp;comma = strchr(quote_two, ',');</div><div>&nbsp; &nbsp; \
&nbsp;}</div><div>&nbsp; &nbsp; &nbsp;else if (!quote_one)</div><div>&nbsp; &nbsp; \
&nbsp;{</div><div>- &nbsp; &nbsp; &nbsp; &nbsp;comma = index(data, ',');</div><div>+ \
&nbsp; &nbsp; &nbsp; &nbsp;comma = strchr(data, ',');</div><div>&nbsp; &nbsp; \
&nbsp;}</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp;if (comma)</div><div>@@ \
-1471,7 +1471,7 @@</div><div>&nbsp; &nbsp; &nbsp;PatternMatchData \
*ds_idx;</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp;/* clear out the temp buffer \
*/</div><div>- &nbsp; &nbsp;bzero(tmp_buf, MAX_PATTERN_SIZE);</div><div>+ &nbsp; \
&nbsp;memset(tmp_buf, '\0', MAX_PATTERN_SIZE);</div><div>&nbsp;</div><div>&nbsp; \
&nbsp; &nbsp;if (rule == NULL)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;ParseError("ParsePattern Got Null enclosed in quotation marks \
(\")!");</div><div>@@ -1486,7 +1486,7 @@</div><div>&nbsp; &nbsp; \
&nbsp;}</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp;/* find the start of the data \
*/</div><div>- &nbsp; &nbsp;start_ptr = index(rule, '"');</div><div>+ &nbsp; \
&nbsp;start_ptr = strchr(rule, '"');</div><div>&nbsp;</div><div>&nbsp; &nbsp; \
&nbsp;if (start_ptr != rule)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;ParseError("Content data needs to be enclosed in quotation marks \
(\")!");</div><div>@@ -1530,8 +1530,7 @@</div><div>&nbsp; &nbsp; &nbsp;dummy_end = \
(dummy_idx + size);</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp;/* why is this \
buffer so small? */</div><div>- &nbsp; &nbsp;bzero(hex_buf, 3);</div><div>- &nbsp; \
&nbsp;memset(hex_buf, '0', 2);</div><div>+ &nbsp; &nbsp;memset(hex_buf, '\0', \
3);</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp;/* BEGIN BAD JUJU..... \
*/</div><div>&nbsp; &nbsp; &nbsp;while(idx &lt; end_ptr)</div><div>@@ -1640,8 +1639,7 \
@@</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;strtol(hex_buf, (char \
**) NULL, 16)&amp;0xFF;</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;dummy_size++;</div><div>- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bzero(hex_buf, \
3);</div><div>- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;memset(hex_buf, '0', 2);</div><div>+ &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp;memset(hex_buf, '\0', 3);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;}</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else</div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;{</div><div>@@ -2486,7 +2484,7 @@</div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;data++;</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp;/* grab everything \
between the starting " and the end one */</div><div>- &nbsp; &nbsp;sptr = index(data, \
'"');</div><div>+ &nbsp; &nbsp;sptr = strchr(data, '"');</div><div>&nbsp; &nbsp; \
&nbsp;eptr = strrchr(data, '"');</div><div>&nbsp;</div><div>&nbsp; &nbsp; \
&nbsp;if(sptr != NULL &amp;&amp; eptr != NULL)</div><div>@@ -2545,8 +2543,8 \
@@</div><div>&nbsp; &nbsp; &nbsp;}</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp;/* \
clear the line and rule buffers */</div><div>- &nbsp; &nbsp;bzero((char *) buf, \
STD_BUF);</div><div>- &nbsp; &nbsp;bzero((char *) rule_buf, STD_BUF);</div><div>+ \
&nbsp; &nbsp;memset((char *) buf, '\0', STD_BUF);</div><div>+ &nbsp; \
&nbsp;memset((char *) rule_buf, '\0', STD_BUF);</div><div>&nbsp; &nbsp; \
&nbsp;frazes_count = 0;</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp;/* loop thru \
each list_file line and content to the rule */</div><div><span class="" \
style="white-space: pre;">	</span>&nbsp;</div><div>In directory \
'snort-2.9.5/src/detection-plugins', file&nbsp;</div><div>'sp_tcp_win_check.c', the \
following patch file replaces</div><div>calls to index() with \
strchr():</div><div><br></div><div>--- sp_tcp_win_check.c.orig &nbsp; &nbsp; \
2013-07-18 12:36:11.167880131 -0700</div><div>+++ sp_tcp_win_check.c &nbsp;2013-07-18 \
12:36:49.028881611 -0700</div><div>@@ -205,7 +205,7 @@</div><div>&nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp;start = &amp;data[0];</div><div>&nbsp; &nbsp; \
&nbsp;}</div><div>&nbsp;</div><div>- &nbsp; &nbsp;if(index(start, (int) 'x') == NULL \
&amp;&amp; index(start, (int)'X') == NULL)</div><div>+ &nbsp; &nbsp;if(strchr(start, \
(int) 'x') == NULL &amp;&amp; strchr(start, (int)'X') == NULL)</div><div>&nbsp; \
&nbsp; &nbsp;{</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;win_size = \
SnortStrtolRange(start, &amp;endTok, 10, 0, UINT16_MAX);</div><div>&nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp;if ((endTok == start) || (*endTok != '\0'))</div><div>@@ -217,10 \
+217,10 @@</div><div>&nbsp; &nbsp; &nbsp;else</div><div>&nbsp; &nbsp; \
&nbsp;{</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* hex? */</div><div>- &nbsp; \
&nbsp; &nbsp; &nbsp;start = index(data,(int)'x');</div><div>+ &nbsp; &nbsp; &nbsp; \
&nbsp;start = strchr(data,(int)'x');</div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;if(!start)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>- &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;start = index(data,(int)'X');</div><div>+ &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;start = strchr(data,(int)'X');</div><div>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if \
(start)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div><br></div><div>In \
directory 'snort-2.9.5/src/detection-plugins', file&nbsp;</div><div>'sp_replace.c', \
the following patch file replaces calls</div><div>to index() with strchr() &lt;this \
also contains a previous</div><div>patch for converting bzero() calls to \
memset()&gt;:</div><div><span class="" style="white-space: \
pre;">		</span>&nbsp;</div><div>--- sp_replace.c.orig &nbsp; 2013-07-18 \
08:48:41.818893728 -0700</div><div>+++ sp_replace.c &nbsp; &nbsp; &nbsp; \
&nbsp;2013-07-18 12:38:44.570878841 -0700</div><div>@@ -111,7 +111,7 \
@@</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;file_name, \
file_line);</div><div>&nbsp; &nbsp; &nbsp;}</div><div>&nbsp; &nbsp; &nbsp;/* clear \
out the temp buffer */</div><div>- &nbsp; &nbsp;bzero(tmp_buf, \
MAX_PATTERN_SIZE);</div><div>+ &nbsp; &nbsp;memset(tmp_buf, '\0', \
MAX_PATTERN_SIZE);</div><div>&nbsp;</div><div>&nbsp; &nbsp; \
&nbsp;while(isspace((int)*rule))</div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;rule++;</div><div>@@ -122,7 +122,7 @@</div><div>&nbsp; &nbsp; \
&nbsp;}</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp;/* find the start of the data \
*/</div><div>- &nbsp; &nbsp;start_ptr = index(rule, '"');</div><div>+ &nbsp; \
&nbsp;start_ptr = strchr(rule, '"');</div><div>&nbsp;</div><div>&nbsp; &nbsp; \
&nbsp;if(start_ptr == NULL)</div><div>&nbsp; &nbsp; &nbsp;{</div><div>@@ -163,8 \
+163,7 @@</div><div>&nbsp; &nbsp; &nbsp;dummy_end = (dummy_idx + \
size);</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp;/* why is this buffer so small? \
*/</div><div>- &nbsp; &nbsp;bzero(hex_buf, 3);</div><div>- &nbsp; \
&nbsp;memset(hex_buf, '0', 2);</div><div>+ &nbsp; &nbsp;memset(hex_buf, '\0', \
3);</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp;/* BEGIN BAD JUJU..... \
*/</div><div>&nbsp; &nbsp; &nbsp;while(idx &lt; end_ptr)</div><div>@@ -269,8 +268,7 \
@@</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;strtol(hex_buf, (char \
**) NULL, 16)&amp;0xFF;</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;dummy_size++;</div><div>- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bzero(hex_buf, \
3);</div><div>- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;memset(hex_buf, '0', 2);</div><div>+ &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp;memset(hex_buf, '\0', 3);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;}</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else</div><div>&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;{</div><div><span class="" style="white-space: \
pre;">							</span>&nbsp;</div><div><br></div><div>In directory \
'snort-2.9.5/src/dynamic-preprocessors/sdf',</div><div>file \
&nbsp;'sdf_pattern_match.c', the following patch file</div><div>replaces calls to \
index() with strchr():</div><div><span class="" style="white-space: \
pre;">							</span>&nbsp;</div><div>--- sdf_pattern_match.c.orig &nbsp; \
&nbsp;2013-07-18 12:40:51.368879507 -0700</div><div>+++ sdf_pattern_match.c \
2013-07-18 12:41:17.518883291 -0700</div><div>@@ -82,7 +82,7 @@</div><div>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp;return;</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp;/* \
Locate first '{' */</div><div>- &nbsp; &nbsp;bracket_index = index(*pii, \
'{');</div><div>+ &nbsp; &nbsp;bracket_index = strchr(*pii, \
'{');</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp;/* Brackets at the beginning \
have nothing to modify. */</div><div>&nbsp; &nbsp; &nbsp;if (bracket_index == \
*pii)</div><div>@@ -97,7 +97,7 @@</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* \
Ignore escaped brackets */</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if \
((bracket_index &gt; *pii) &amp;&amp; (*(bracket_index-1) == '\\'))</div><div>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;bracket_index = index(bracket_index+1, '{');</div><div>+ &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp;bracket_index = strchr(bracket_index+1, '{');</div><div>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;continue;</div><div>&nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp;}</div><div>&nbsp;</div><div>@@ -133,7 +133,7 @@</div><div>&nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp;num_brackets++;</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp;/* Next bracket */</div><div>- &nbsp; &nbsp; &nbsp; &nbsp;bracket_index \
= index(bracket_index+1, '{');</div><div>+ &nbsp; &nbsp; &nbsp; &nbsp;bracket_index = \
strchr(bracket_index+1, '{');</div><div>&nbsp; &nbsp; \
&nbsp;}</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp;/* By this point, the brackets \
all match up. */</div><div><span class="" style="white-space: \
pre;">	</span>&nbsp;</div><div><br></div><div>In directory \
'snort-2.9.5/src/dynamic-preprocessors/ftptelnet',</div><div>file 'pp_ftp.c', the \
following patch file replaces calls to</div><div>index() with \



------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk

_______________________________________________
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!

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic