From nobody Sat Sep 23 21:09:04 2023 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 4RtMFX2jZWz4vFWn; Sat, 23 Sep 2023 21:09:04 +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 4RtMFX2C87z3SXZ; Sat, 23 Sep 2023 21:09:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695503344; 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=mJ37n8lj02utSW/PnpV+xTt7RdMAs1f/R6OYpLB/+PY=; b=RynYBE3owJ4uGR2vBCrreFtANtVLQXQdqrlJimm8JibgVx3xmQGzeo13Y1t8Lr0XxNg6JB uwLkYN9WGvhsNagXWbmfO4k6AsHxqtIql8Xzyemg7LjJRX4jJOI8pXd/v/4mbSpoHdmzEb F1J/JcOSVriQ6yP7PQvDpWc5bBeFP4BbTVzeqlVFIiEXRj0VK2ENa5N5nt+wBoV+wrYO8L hQrIfr6HRMtJIxffqakAPhGl6AOsEUcYa1UQhF1uL1c5vEIZ5ffxwB3zIMpm2iSFmBPABC ja7q+ysyBdAtxS34MwFrQqYn3ZbpzTeQALlaiPM+aTyep5Pmc+TaQbCm8GPPpg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695503344; a=rsa-sha256; cv=none; b=X9EKgddZulI6Rin+pFywgms/EVAfhPIYV+ll+7mto3L/b9e8qMBMBTKx35zHKxWLQ7HBzw /OIpEpzW5Bu+tordEyxVHiv4vS4HTuMczHNJP2SSwrr5qjtyFSlDp1FkFX9pgI601IXOiY aX/GBiq4hXf7pDdfzJpKsDtBPSDq5mUowV9RfUIRw6YMXBjYtCJcrF0V4sBiJWuKi2gwbF e0laMJccRCF76y6olFZGFMkgI1Jr0Wh8KbTvqpCuKzedN+66mP1na1EpuU7oaNAde4JLI0 oYRduW0Ug377zd7kDlSSkmqmnewtHxJxw7Mnh4ApOBjP2+wS6QvO89bUu5TRrA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695503344; 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=mJ37n8lj02utSW/PnpV+xTt7RdMAs1f/R6OYpLB/+PY=; b=wETym1mO7dY4j7aS7atlwLO6ESS85VttGmHwlgEMvRUCS1+1AXgCDhXwNiR4QoyORD+P7x DWlrMs5+L2bxK1QdKs3sZQCeot7buWZ0j245RmxK+zBCPR6p47iz/5pJkkL9msTbidQPXx buAaBWHOC1PNoR3kmM9HVIw4k+sbBiTdvhCyi9Ljw5HDk7oY7y5XzF7YEJPw4lEhULJff1 QY1hIDYCjSNWW3eAjZckaZbrvmpsG5ZQsx/LmUuinZcNiNtwXHeFnaFjURehwb60L1GiiH ibBnhbDueBdOzzy9AgTYsFtloYpff2xiBkycTPHbClRvQfwaLNqKybuhlIn1Qw== 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 4RtMFX1GVtz4cZ; Sat, 23 Sep 2023 21:09:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38NL942S071351; Sat, 23 Sep 2023 21:09:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38NL94uB071348; Sat, 23 Sep 2023 21:09:04 GMT (envelope-from git) Date: Sat, 23 Sep 2023 21:09:04 GMT Message-Id: <202309232109.38NL94uB071348@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Garance A Drosehn Subject: git: ca927128bf6a - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: ca927128bf6a92abce27151fbb1ab112fd2a8385 Auto-Submitted: auto-generated The branch stable/13 has been updated by gad: URL: https://cgit.FreeBSD.org/src/commit/?id=ca927128bf6a92abce27151fbb1ab112fd2a8385 commit ca927128bf6a92abce27151fbb1ab112fd2a8385 Author: Garance A Drosehn AuthorDate: 2021-12-30 20:45:13 +0000 Commit: Garance A Drosehn CommitDate: 2023-09-23 21:04:40 +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: (cherry picked from commit b7b447fd4ca327faa99b2f16e6cbd61c86c75f04) --- 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 06bdffdda084..792ad3e1727d 100644 --- a/usr.sbin/newsyslog/ptimes.c +++ b/usr.sbin/newsyslog/ptimes.c @@ -277,6 +277,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;