From nobody Thu Oct 07 03:08:13 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 907BF12DA568; Thu, 7 Oct 2021 03:08:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HPx8s3hcNz4mdD; Thu, 7 Oct 2021 03:08:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5ECEB412A; Thu, 7 Oct 2021 03:08:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19738DYb034203; Thu, 7 Oct 2021 03:08:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19738Dts034202; Thu, 7 Oct 2021 03:08:13 GMT (envelope-from git) Date: Thu, 7 Oct 2021 03:08:13 GMT Message-Id: <202110070308.19738Dts034202@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Eugene Grosbein Subject: git: 7cf79c60fee5 - stable/13 - syslogd: undo regression after r326573 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: eugen X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7cf79c60fee596c03f4e757a713050c9331f0524 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=7cf79c60fee596c03f4e757a713050c9331f0524 commit 7cf79c60fee596c03f4e757a713050c9331f0524 Author: Eugene Grosbein AuthorDate: 2021-09-27 07:25:21 +0000 Commit: Eugene Grosbein CommitDate: 2021-10-07 03:07:32 +0000 syslogd: undo regression after r326573 Restore ability for our syslogd to collect pre-RFC3164 formatted messages from remote hosts that was broken with r326573. Note that parsing of RFC5424 format not changed. (cherry picked from commit 3b4cc56e524ac947ba0e6571e2c455139c2839ec) --- usr.sbin/syslogd/syslogd.c | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index d8a2c0a5680e..9ed0b8098753 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1357,31 +1357,25 @@ parsemsg(const char *from, char *msg) size_t i; int pri; + i = -1; + pri = DEFUPRI; + /* Parse PRI. */ - if (msg[0] != '<' || !isdigit(msg[1])) { - dprintf("Invalid PRI from %s\n", from); - return; - } - for (i = 2; i <= 4; i++) { - if (msg[i] == '>') - break; - if (!isdigit(msg[i])) { - dprintf("Invalid PRI header from %s\n", from); - return; + if (msg[0] == '<' && isdigit(msg[1])) { + for (i = 2; i <= 4; i++) { + if (msg[i] == '>') { + errno = 0; + n = strtol(msg + 1, &q, 10); + if (errno == 0 && *q == msg[i] && n >= 0 && n <= INT_MAX) { + pri = n; + msg += i + 1; + i = 0; + } + break; } + } } - if (msg[i] != '>') { - dprintf("Invalid PRI header from %s\n", from); - return; - } - errno = 0; - n = strtol(msg + 1, &q, 10); - if (errno != 0 || *q != msg[i] || n < 0 || n >= INT_MAX) { - dprintf("Invalid PRI %ld from %s: %s\n", - n, from, strerror(errno)); - return; - } - pri = n; + if (pri &~ (LOG_FACMASK|LOG_PRIMASK)) pri = DEFUPRI; @@ -1394,8 +1388,7 @@ parsemsg(const char *from, char *msg) pri = LOG_MAKEPRI(LOG_USER, LOG_PRI(pri)); /* Parse VERSION. */ - msg += i + 1; - if (msg[0] == '1' && msg[1] == ' ') + if (i == 0 && msg[0] == '1' && msg[1] == ' ') parsemsg_rfc5424(from, pri, msg + 2); else parsemsg_rfc3164(from, pri, msg);