aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2017-02-25 00:12:29 +0000
committerEnji Cooper <ngie@FreeBSD.org>2017-02-25 00:12:29 +0000
commit15f0eea57403ba18177a16150a27399b20f81b60 (patch)
tree278bf55880b0c8504696e24f599f3e49be825e24 /usr.sbin
parent35a419a2cbdc36148de9d6211f1e2051cc2138a1 (diff)
downloadsrc-15f0eea57403ba18177a16150a27399b20f81b60.tar.gz
src-15f0eea57403ba18177a16150a27399b20f81b60.zip
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 <john.bauman@isilon.com> MFC after: 2 weeks Sponsored by: Dell EMC Isilon
Notes
Notes: svn path=/head/; revision=314233
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/syslogd/syslogd.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 259158d280d1..c7c2c7ef88a2 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -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 char *from, int flags)
* 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 char *from, int flags)
timestamp = ctime(&now) + 4;
} else {
timestamp = msg;
- msg += 16;
- msglen -= 16;
+ msg += MAXDATELEN;
+ msglen -= MAXDATELEN;
}
/* skip leading blanks */