From owner-svn-src-all@freebsd.org Sat Feb 25 00:12:31 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2BF70CEC8D9; Sat, 25 Feb 2017 00:12:31 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D3FDC1FFD; Sat, 25 Feb 2017 00:12:30 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v1P0CTe9037092; Sat, 25 Feb 2017 00:12:29 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v1P0CTVC037091; Sat, 25 Feb 2017 00:12:29 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201702250012.v1P0CTVC037091@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 25 Feb 2017 00:12:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314233 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Feb 2017 00:12:31 -0000 Author: ngie Date: Sat Feb 25 00:12:29 2017 New Revision: 314233 URL: https://svnweb.freebsd.org/changeset/base/314233 Log: 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) Submitted by: John Bauman MFC after: 2 weeks Sponsored by: Dell EMC Isilon Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Sat Feb 25 00:09:26 2017 (r314232) +++ head/usr.sbin/syslogd/syslogd.c Sat Feb 25 00:12:29 2017 (r314233) @@ -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) @@ -212,7 +214,7 @@ struct filed { #define fu_pipe_pname f_un.f_pipe.f_pname #define fu_pipe_pid f_un.f_pipe.f_pid 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 */ @@ -1034,7 +1036,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; @@ -1043,8 +1045,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 */