Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Mar 2017 04:55:07 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r315125 - stable/11/usr.sbin/syslogd
Message-ID:  <201703120455.v2C4t7nC054478@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Sun Mar 12 04:55:06 2017
New Revision: 315125
URL: https://svnweb.freebsd.org/changeset/base/315125

Log:
  MFC r314233:
  
  Parameterize out the length of struct filed->f_lasttime as `MAXDATELEN`
  
  This removes the hardcoded value for the field (16) and the equivalent
  hardcoded lengths in logmsg(..).
  
  This change is being done to help stage future work to add RFC5424/RFC5434
  support to syslogd(8).
  
  Obtained from:	Isilon OneFS (dcd33d13da) (as part of a larger change)

Modified:
  stable/11/usr.sbin/syslogd/syslogd.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/syslogd/syslogd.c
==============================================================================
--- stable/11/usr.sbin/syslogd/syslogd.c	Sun Mar 12 04:55:02 2017	(r315124)
+++ stable/11/usr.sbin/syslogd/syslogd.c	Sun Mar 12 04:55:06 2017	(r315125)
@@ -68,6 +68,8 @@ __FBSDID("$FreeBSD$");
  * Priority comparison code by Harlan Stenn.
  */
 
+/* Maximum number of characters in time of last occurrence */
+#define	MAXDATELEN	16
 #define	MAXLINE		1024		/* maximum line length */
 #define	MAXSVLINE	MAXLINE		/* maximum saved line length */
 #define	DEFUPRI		(LOG_USER|LOG_NOTICE)
@@ -197,7 +199,7 @@ struct filed {
 		} f_pipe;
 	} f_un;
 	char	f_prevline[MAXSVLINE];		/* last message logged */
-	char	f_lasttime[16];			/* time of last occurrence */
+	char	f_lasttime[MAXDATELEN];		/* time of last occurrence */
 	char	f_prevhost[MAXHOSTNAMELEN];	/* host from which recd. */
 	int	f_prevpri;			/* pri of f_prevline */
 	int	f_prevlen;			/* length of f_prevline */
@@ -974,7 +976,7 @@ logmsg(int pri, const char *msg, const c
 	 * Check to see if msg looks non-standard.
 	 */
 	msglen = strlen(msg);
-	if (msglen < 16 || msg[3] != ' ' || msg[6] != ' ' ||
+	if (msglen < MAXDATELEN || msg[3] != ' ' || msg[6] != ' ' ||
 	    msg[9] != ':' || msg[12] != ':' || msg[15] != ' ')
 		flags |= ADDDATE;
 
@@ -983,8 +985,8 @@ logmsg(int pri, const char *msg, const c
 		timestamp = ctime(&now) + 4;
 	} else {
 		timestamp = msg;
-		msg += 16;
-		msglen -= 16;
+		msg += MAXDATELEN;
+		msglen -= MAXDATELEN;
 	}
 
 	/* skip leading blanks */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703120455.v2C4t7nC054478>