[Snort-devel] small bugfix in util.c

Dagobert Kellner md at ...2604...
Mon Aug 16 08:03:11 EDT 2004


Hello,

I found a small bug in util.c in the function ts_print which generates the wrong date (always 01/01) in the alert-log when using snort on a sparc64 with FreeBSD 5.2.1 .

According to the tcpdump sources I patched the util.c, from the snort 2.1.3.  Now snort works on a sparc64 with FreeBSD 5.2.1 without problems. I could not test it on other machines/OS, but it schould also work.


Greetings


Dagobert Kellner


-------------- next part --------------
--- util.c.orig	Tue Aug  3 10:30:06 2004
+++ util.c	Tue Aug  3 10:30:46 2004
@@ -291,6 +291,7 @@
 void ts_print(register const struct timeval *tvp, char *timebuf)
 {
     register int s;
+    time_t Time;
     struct timeval tv;
     struct timezone tz;
     struct tm *lt;    /* place to stick the adjusted clock data */
@@ -303,17 +304,18 @@
         gettimeofday(&tv, &tz);
         tvp = &tv;
     }
+    
+    s = (tvp->tv_sec + thiszone) % 86400;
+    Time = (tvp->tv_sec + thiszone) - s;
 
     if(!pv.use_utc)
     {
-        lt = localtime((time_t *) & tvp->tv_sec);
+        lt = localtime(&Time);
     }
     else
     {
-        lt = gmtime((time_t *) &tvp->tv_sec);
+        lt = gmtime(&Time);
     }
-
-    s = (tvp->tv_sec + thiszone) % 86400;
 
     if(pv.include_year)
     {


More information about the Snort-devel mailing list