[syslog-ng]Double timestamps cause DB issue

Balazs Scheidler syslog-ng@lists.balabit.hu
Sat, 26 Apr 2003 09:43:09 +0200


On Fri, Apr 25, 2003 at 03:21:55PM -0400, Robin Brown wrote:
> Yes, of course I will test it.

against 1.6.0rc3:

Index: log.c
===================================================================
RCS file: /var/cvs/syslog-ng/syslog-ng/src/log.c,v
retrieving revision 1.29
diff -u -r1.29 log.c
--- log.c	8 Jan 2003 09:31:37 -0000	1.29
+++ log.c	26 Apr 2003 07:42:27 -0000
@@ -86,11 +86,27 @@
 
 	/* If the next chars look like a date, then read them as a date. */
 	if (left >= 15) {
-  	        /* Expected buffer format: MMM DD HH:MM:SS ... */
+                struct tm tm, *nowtm;
 
-	        if (src[3] == ' ' && src[6] == ' ' &&
-		    src[9] == ':' && src[12] == ':') {
-	                struct tm tm, *nowtm;
+		if (left >= 21 &&
+		    src[3] == ' ' && src[6] == ' ' && src[11] == ' ' &&
+		    src[14] == ':' && src[17] == ':' && src[20] ==':') {
+			/* PIX time stamp, format: MMM DD YYYY HH:MM:SS: */
+			
+			src[20] = 0;
+			memset(&tm, 0, sizeof(tm));
+			strptime(src, "%b %e %Y %H:%M:%S", &tm);
+			tm.tm_isdst = -1;
+			lm->date = ol_string_alloc(16);
+			strftime(lm->date->data, 16, "%b %e %H:%M:%S", &tm);
+			src[20] = ':';
+			src += 21;
+			left -= 21;
+			lm->stamp = mktime(&tm);
+		}
+	        else if (src[3] == ' ' && src[6] == ' ' &&
+		         src[9] == ':' && src[12] == ':') {
+	  	        /* Expected buffer format: MMM DD HH:MM:SS ... */
 
 			/* Just read the buffer data into a textual
 			   datestamp. */


-- 
Bazsi
PGP info: KeyID 9AF8D0A9 Fingerprint CD27 CFB0 802C 0944 9CFD 804E C82C 8EB1