diff options
author | ngie <ngie@FreeBSD.org> | 2017-03-12 04:55:02 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2017-03-12 04:55:02 +0000 |
commit | 61ceead6328697196d40625b6b3e634c807fc0ae (patch) | |
tree | 5266b8c0d050c4a97af8767cea3c7dd31427cdc0 /usr.sbin | |
parent | 8ed55657283c8b061c5d860c4737bbb17b9077c7 (diff) | |
download | FreeBSD-src-61ceead6328697196d40625b6b3e634c807fc0ae.zip FreeBSD-src-61ceead6328697196d40625b6b3e634c807fc0ae.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)
Diffstat (limited to 'usr.sbin')
-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 5dd32ab..3d5429f 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) @@ -185,7 +187,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 */ @@ -939,7 +941,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; @@ -948,8 +950,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 */ |