From nobody Thu Dec 30 21:03:36 2021 X-Original-To: dev-commits-src-all@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 C37F61919479; Thu, 30 Dec 2021 21:03:36 +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 4JQ12w3cNXz3tcw; Thu, 30 Dec 2021 21:03:36 +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 5BA8A1F666; Thu, 30 Dec 2021 21:03:36 +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 1BUL3a4B051171; Thu, 30 Dec 2021 21:03:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BUL3aj4051170; Thu, 30 Dec 2021 21:03:36 GMT (envelope-from git) Date: Thu, 30 Dec 2021 21:03:36 GMT Message-Id: <202112302103.1BUL3aj4051170@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Garance A Drosehn Subject: git: b7b447fd4ca3 - main - When parsing a rule to rotate log files on a specific week day, parseDWM() can advance the time to the next week. If the next week is in the next month, then tm_mon is incremented. However, the increment was failing to handle the wraparound from December to January, so when parsing a rule during the last week of the December, the month would advance to month 12. This triggered an out-of-bounds read of the mtab[] array in days_pmonth() after parseDWM() returned. To fix, this change resets the month to January and increment the year when the month increment wraps. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gad X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b7b447fd4ca327faa99b2f16e6cbd61c86c75f04 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640898216; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=G8ogV2lQH9gN1mTLyMv1qeQnky15d1QwR1XJAbTQuIc=; b=klZpuzpnY/teFWROsOa8NJcYSPBXm1yjvxpcEqXh6j/d6syTQ2QfJJ4n8DzKbpxofO3PTh NYpQbmeL85DtkNkprUY/vNgbrdtDQqCcQxxagArOPE2rVhEAY2zMlqHlQMr6CI/g3s1gF5 ffIUyMoQvIeCS8NLmXI0wCAf8SLmjbBm1VjuTlwryfHeQ/FjFI2YwbPN/sSqD4EgUKnLF+ 1mymegEfqE+ELlmSdOYBqk+OY12J2PVDUufrK05N579KiJd9irzKha40vxlk5OXRDVe8wc xWjdSOUrVN87EuIrp4PRTsXxdzbaIcmtfkmsjorbsd5BshFKweuUUoDujjY+5w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640898216; a=rsa-sha256; cv=none; b=v2vu7kxkLARpuzC4WhwBpvxtL0ZXzyQWVuB4mMu83py3VPxYot1dsbv+eOz4nfXbJQqi7s L4mVtfEp6j04kU5oFLr37KKXjat5EC7TjIUPTDpYleP/2K4wjr+rDMz2aUt1OOMna4dhfN pFsQuOKatLstvjhwHQvJkX6DiS0n6VI1qycdXE8xQJ9QJfDxgGtcNDT6ByUG0jXWsC746h 20XbSkczPR0YO40EPI8TfbS/GPTmS7BHsFD85RTVvOcsiGiluqepBnneaI/xeYIAXbwASU plyorz8LBiGGWd54rqlWk72AekO6CIkL2wJcLdX6QGhl2LWk6sRGz3AbOmp2QA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by gad: URL: https://cgit.FreeBSD.org/src/commit/?id=b7b447fd4ca327faa99b2f16e6cbd61c86c75f04 commit b7b447fd4ca327faa99b2f16e6cbd61c86c75f04 Author: Garance A Drosehn AuthorDate: 2021-12-30 20:45:13 +0000 Commit: Garance A Drosehn CommitDate: 2021-12-30 20:45:13 +0000 When parsing a rule to rotate log files on a specific week day, parseDWM() can advance the time to the next week. If the next week is in the next month, then tm_mon is incremented. However, the increment was failing to handle the wraparound from December to January, so when parsing a rule during the last week of the December, the month would advance to month 12. This triggered an out-of-bounds read of the mtab[] array in days_pmonth() after parseDWM() returned. To fix, this change resets the month to January and increment the year when the month increment wraps. The default rule for /var/log/weekly.log triggers this during the last week of December each year. Reported by: CHERI Obtained from: CheriBSD Reviewed by: jhb Sponsored by: The University of Cambridge, Google Inc. Differential Revision: --- usr.sbin/newsyslog/ptimes.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/usr.sbin/newsyslog/ptimes.c b/usr.sbin/newsyslog/ptimes.c index b7b993f01959..d54ca1d40050 100644 --- a/usr.sbin/newsyslog/ptimes.c +++ b/usr.sbin/newsyslog/ptimes.c @@ -279,6 +279,10 @@ parseDWM(struct ptime_data *ptime, const char *s) if (tm.tm_mday > daysmon) { tm.tm_mon++; tm.tm_mday = tm.tm_mday - daysmon; + if (tm.tm_mon >= 12) { + tm.tm_mon = 0; + tm.tm_year++; + } } } break;