When parsing UDP messages skip optional hostname as described by

RFC 3164.

PR:		200933
Submitted by:	maxim
Reported by:	Konstantin Pavlov <thresh nginx.com>
MFC after:	2 weeks
This commit is contained in:
Gleb Smirnoff 2017-11-08 16:45:53 +00:00
parent e1b7ce1fa0
commit b9a63e5c3a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=325558

View File

@ -1034,7 +1034,7 @@ static void
logmsg(int pri, const char *msg, const char *from, int flags)
{
struct filed *f;
int i, fac, msglen, prilev;
int i, j, fac, msglen, prilev;
const char *timestamp;
char prog[NAME_MAX+1];
char buf[MAXLINE+1];
@ -1077,6 +1077,19 @@ logmsg(int pri, const char *msg, const char *from, int flags)
prilev = LOG_PRI(pri);
/* skip hostname, see RFC 3164 */
for (i = 0, j = 0; i < NAME_MAX; i++) {
if (isspace(msg[i])) {
j = i + 1;
}
if (msg[i] == ':')
break;
}
if (j <= msglen) {
msg += j;
msglen -= j;
}
/* extract program name */
for (i = 0; i < NAME_MAX; i++) {
if (!isprint(msg[i]) || msg[i] == ':' || msg[i] == '[' ||