diff options
author | ngie <ngie@FreeBSD.org> | 2017-03-12 04:55:06 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2017-03-12 04:55:06 +0000 |
commit | 64e107841d6d647e515564b4c840193d77a957f8 (patch) | |
tree | 179c801dc82dffdfe943ce04a1f5e7b24c7c9f2d | |
parent | 672c27440d9bb38769ea9cdbc3675228c5da822d (diff) | |
download | FreeBSD-src-64e107841d6d647e515564b4c840193d77a957f8.zip FreeBSD-src-64e107841d6d647e515564b4c840193d77a957f8.tar.gz |
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)
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index fa51669..490bbc0 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) @@ -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 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; @@ -983,8 +985,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 */ |