From nobody Mon Jul 7 17:23:01 2025 X-Original-To: dev-commits-src-main@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 4bbWKL2jPXz60kVM; Mon, 07 Jul 2025 17:23:02 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bbWKK59Jqz3dQk; Mon, 07 Jul 2025 17:23:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751908981; 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=pRVeQkYsmiWTkLQ/D+RukGryFJ6jk2U2HlFI1GXVFKo=; b=YzO7IfJbleH3vnrMytYpEIO0ThidC76KiivA8Z8tA8BwrqeZdp8WdyrGLtvc7uJ7x/JWw9 SBWVSyDC3193uUaNhh+MOgMCJALD5v/9KzGgI7r73pzTvn4Ibl8DuPVfLkR6HsSSkXJfws BDwV/46glNMpX/OQw8o5OdgeFEIsddSs/T7zKsaw/jX0p5e6XVCLAXEi9dcx1BxbivWAUE jSR1Ei8mH8ytzKGzxdqn+CRy+/qro1jGm+Q3Dx50vPUwFFXcXCAsmiNGuVK1RMWl7R09V5 TGiDSl5BxVTWxna/QfCWVtFqLZbtI6cNOoCnevyhSAZ2kOsjdF2KJg2IjLW5YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751908981; 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=pRVeQkYsmiWTkLQ/D+RukGryFJ6jk2U2HlFI1GXVFKo=; b=WW9We64EYFglr3P0vl2NkKbDsT/xfDJwkhkUwoucjkVgajH3LJvddy7kAZ00T8dBWLa+Hn 2/dZ9qo1AqOlr3tEHdyBhvOVYXz3Ntlu85zwg45GMZJuvkUNNsAbk04Kk2SSHykT8indi9 MmPJu0SHsoGRcfzfkRJJzBEDlyqH0cBqhGtU9UoSQbVtjvq/+Bq1D/vhQPNjNlrDfGq9dT N2QGpJJU2syXN12TolbnaRrkthUQSFuSKUn56VbwCvA56VUbMm+aNBbe+8eYhXq0dGEjw5 fh/wR2q/E3RvD3d855Fxwu3SHBvo/0ZEWAFlXiFEsKHruVO1Ul2WZ1BZSBMQWg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1751908981; a=rsa-sha256; cv=none; b=cjsWfh59TGdrKk2aIoP620lrLqT5fI6Hh1RiLIyamMSmyzsf3Uy9SXTmXtTQeSjE3vZ3S9 AyAwe3JW6LJmaiCdsY3E9uRmtw35KjZ7Erd/+eJlqxh6EmxHQ1XtQotoO3JC3jXXDDuAft XmgffipI5aMrnxcFir+OPP3A9uLjIVEW3uxJBRzdBZQCMFAdJKHgCkBa2N+zZAefRzzxre fi7t4t6PHmu7Fn2G+E+LThivOLdfEEG81p9weAh8rG2qNtyUwoAAcNDG2bG4fPidQyf/1G PlesIM9eOigh3uEOXacrlzWny9dE3w/AjwgJsKj9LEadIzJrS0A9rjGBO4zlcw== 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 4bbWKK30bcz10b0; Mon, 07 Jul 2025 17:23:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 567HN1QO080631; Mon, 7 Jul 2025 17:23:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 567HN1uk080628; Mon, 7 Jul 2025 17:23:01 GMT (envelope-from git) Date: Mon, 7 Jul 2025 17:23:01 GMT Message-Id: <202507071723.567HN1uk080628@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 10ed5b90e46f - main - mfiutil: Handle truncation in mfi_next_learn_time List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 10ed5b90e46f5df329f511c08bd55458f95f1b6c Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=10ed5b90e46f5df329f511c08bd55458f95f1b6c commit 10ed5b90e46f5df329f511c08bd55458f95f1b6c Author: John Baldwin AuthorDate: 2025-07-07 16:37:09 +0000 Commit: John Baldwin CommitDate: 2025-07-07 16:37:09 +0000 mfiutil: Handle truncation in mfi_next_learn_time Only trim the trailing newline if the output from ctime() was not truncated. To simplify the code, use strlcpy() instead of snprintf() since strlcpy() can't fail with a negative size (and the previous code probably didn't handle those errors properly given the int -> size_t conversion). Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D50882 --- usr.sbin/mfiutil/mfi_bbu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/mfiutil/mfi_bbu.c b/usr.sbin/mfiutil/mfi_bbu.c index aa685e438453..3e78e791dfc2 100644 --- a/usr.sbin/mfiutil/mfi_bbu.c +++ b/usr.sbin/mfiutil/mfi_bbu.c @@ -71,8 +71,8 @@ mfi_next_learn_time(uint32_t next_learn_time, char *buf, size_t sz) tm.tm_year = 100; basetime = timegm(&tm); basetime += (time_t)next_learn_time; - len = snprintf(buf, sz, "%s", ctime(&basetime)); - if (len > 0) + len = strlcpy(buf, ctime(&basetime), sz); + if (len < sz) /* Get rid of the newline added by ctime(3). */ buf[len - 1] = '\0'; }