[Snort-devel] Patches for incorrect errno usage

Chris Green cmg at ...835...
Wed Oct 16 16:09:04 EDT 2002


Dave Ockwell-Jenner <doj at ...1609...> writes:

> Whilst building snort 1.9.0 on a SPARC Solaris 8 system, I ran into some
> strange results.  Snort built correctly, but when trying to run it, I came
> across some errors, specifically 'Range problem on offset value'.

Thanks for the patch, I need to change this to actually check for the
error condition correctly rather than just assuming errno is the only
way to be reliable.

>
> Looking at the source, it appears that errno is not reset prior to a
> strtol() call.  From the perror(3C) man page, errno is only set if a
> function call is unsuccessful.
>
> I've patched the source files where I believe this is a problem - hope
> they are useful.  Of course, these patches are against the 1.9.0
> distribution.
>
>
>
> *** threshold.c	Sat Oct  5 09:46:10 2002
> --- threshold.c.doj	Tue Oct  8 20:25:03 2002
> ***************
> *** 271,276 ****
> --- 271,277 ----
>
>       toks = mSplit(args, ",", 3, &num_toks, 0);
>
> +     errno = 0;
>       *threshold = strtol(toks[0], NULL, 10);
>
>       if(errno == ERANGE)
> ***************
> *** 280,285 ****
> --- 281,287 ----
>                   file_name, file_line);
>       }
>
> +     errno = 0;
>       *window = strtol(toks[1], NULL, 10);
>
>       if(errno == ERANGE)
>
>
>
>
>
>
> *** sp_pattern_match.c	Sat Oct  5 09:46:11 2002
> --- sp_pattern_match.c.doj	Tue Oct  8 20:28:00 2002
> ***************
> *** 578,583 ****
> --- 578,584 ----
>       while(isspace((int) *data))
>           data++;
>
> +     errno = 0;
>       idx->offset = strtol(data, NULL, 10);
>
>       if(errno == ERANGE)
> ***************
> *** 619,624 ****
> --- 620,626 ----
>       while(isspace((int) *data))
>           data++;
>
> +     errno = 0;
>       idx->depth = strtol(data, NULL, 10);
>
>       if(errno == ERANGE)
> ***************
> *** 710,715 ****
> --- 712,718 ----
>       while(isspace((int) *data))
>           data++;
>
> +     errno = 0;
>       idx->distance = strtol(data, NULL, 10);
>       idx->check_distance = 1;
>
> ***************
> *** 751,756 ****
> --- 754,760 ----
>       while(isspace((int) *data))
>           data++;
>
> +     errno = 0;
>       idx->within = strtol(data, NULL, 10);
>
>       if(errno == ERANGE)
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Snort-devel mailing list
> Snort-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/snort-devel

-- 
Chris Green <cmg at ...402...>
Eschew obfuscation.




More information about the Snort-devel mailing list