[Snort-devel] Patches for incorrect errno usage

Dave Ockwell-Jenner doj at ...1609...
Tue Oct 8 17:55:02 EDT 2002


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'.

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)





More information about the Snort-devel mailing list