From nobody Thu Jan 9 06:11:20 2025 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 4YTDtw6JWtz5k7DM; Thu, 09 Jan 2025 06:11:20 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YTDtw5NzRz4JP4; Thu, 9 Jan 2025 06:11:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736403080; 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=DKAu1/lUpQO5/sHo2fvd+H2U78UMdxLx6IBUSEj9zP4=; b=EdkWU+AXFl+ulkf3bWdZP8yNIFExFbjYmOzOIJWSNOuoJXfjtiARFQb25tkVKlf+SAY5Kw jlKHYHOULT8PVoMJr3yB6K/4aGlg2irP08C1vvW2FMw2mEIR0WYnybSx4jtCEFAxot9AvQ mnmWujsD7uOa55V/AX3DGohzDlu8OOp46mnSDqZxxiEVMsw62vHUqzoz3b48Fd90RNrF33 /ZlCPd9DjOwKsDf6Ky18/R7oXhzv6lF5w8DJd1+ZVrQmkDhWmv9IwSdVzLZxx5MOnLZ2n7 v68Z/YNMns+t/B21gUJhVyOB/F8/gl47i8rD6/t2hvICNok7Jxjw+gL2XsliBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736403080; 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=DKAu1/lUpQO5/sHo2fvd+H2U78UMdxLx6IBUSEj9zP4=; b=SudEazPgo6vE7QBGNlSAaYcqlv8Ku+X2hCDtgUKCDXl4hHjuCFqWGDpXRffYt3qKi7msNp 9SD0d/cH6OaaUV1QO/EazCeZvvBnqfA+s8OHk7PQuUVBZzB3uvmIvkvr+eFwwIMfBXEKZ5 NXIUHe2/Giu65SZ4zVc9LyxiSR6psMqDEVkd6WHqpQWutOS8j2e27kHJbM/89e86a/r5y2 wKx8E6Cjcrn0ACSQYqFfFNW2XXm0dhulEZM+Rh9aBQzcEXWh+bqkpZlnV5YwmyaG1bNFqJ DqIIeLmT8hYo2oYQhcjJjXCjNpdTovmtHP3WSf1WRKuuGPRr4VpHmSL1CgSePA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736403080; a=rsa-sha256; cv=none; b=c/DyLpfHytd+/9bK3EnXxbAPmQS0v1qKLCRoDeRFJXUlUaiV3NkgHVkDkTivskDKSvQ1qg f6wESuD8HASHhIaNlN5pQ/AaUJEfwf++1dcMMEzB21gK+MTN0BC1NGdTotJCHVk+U6rI9B sq7HiXcYQXGKTu5Yax34Aaov0e7mva1243d7GMWRQH6ggwGmDwaz6mLcsoyPDIQuwIE5ej R5nQWg2swCX83FD+QAsoWcShaDircShLm22sXfDLKNABo19DaUtM0pb8PVPQl3nnO6ARgD m1RtJJUX/Uenu4UK2u+vn6SxHYGVY6o3ECSJ2oyZFDdPCqVp3aIFontmT5+8PA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YTDtw4y9Tz1SSD; Thu, 09 Jan 2025 06:11:20 +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 5096BKTR066616; Thu, 9 Jan 2025 06:11:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5096BKE3066613; Thu, 9 Jan 2025 06:11:20 GMT (envelope-from git) Date: Thu, 9 Jan 2025 06:11:20 GMT Message-Id: <202501090611.5096BKE3066613@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Jason A. Harmening" Subject: git: 6584e5a1c54f - stable/14 - mount(8): Avoid truncation when fstab-formatting unionfs mount info 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: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jah X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 6584e5a1c54ff24ed7c9eb80a884b4e7f54e7288 Auto-Submitted: auto-generated The branch stable/14 has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=6584e5a1c54ff24ed7c9eb80a884b4e7f54e7288 commit 6584e5a1c54ff24ed7c9eb80a884b4e7f54e7288 Author: Jason A. Harmening AuthorDate: 2024-12-22 06:36:30 +0000 Commit: Jason A. Harmening CommitDate: 2025-01-09 06:10:00 +0000 mount(8): Avoid truncation when fstab-formatting unionfs mount info When displaying unionfs mounts in fstab format (`mount -p`), mount(8) currently uses strlcpy to remove the disposition prefix from the mount name returned by getmntinfo(3). But strlcpy, like strcpy before it, does not guarantee correct behavior if the source and destination buffers overlap. Just offset the buffer and avoid the destructive copy in the first place. PR: 283420 Reviewed by: imp (previous version), olce Differential Revision: https://reviews.freebsd.org/D48177 (cherry picked from commit a314c60625af1829b7e12c3a4cedb74d7f69d074) --- sbin/mount/mount.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c index 2fcc94e40818..bb84d9696d12 100644 --- a/sbin/mount/mount.c +++ b/sbin/mount/mount.c @@ -901,9 +901,11 @@ void putfsent(struct statfs *ent) { struct fstab *fst; + const char *mntfromname; char *opts, *rw; int l; + mntfromname = ent->f_mntfromname; opts = NULL; /* flags2opts() doesn't return the "rw" option. */ if ((ent->f_flags & MNT_RDONLY) != 0) @@ -914,16 +916,14 @@ putfsent(struct statfs *ent) opts = flags2opts(ent->f_flags); opts = catopt(rw, opts); - if (strncmp(ent->f_mntfromname, "", 7) == 0 || - strncmp(ent->f_mntfromname, "", 7) == 0) { - strlcpy(ent->f_mntfromname, - (strnstr(ent->f_mntfromname, ":", 8) +1), - sizeof(ent->f_mntfromname)); + if (strncmp(mntfromname, ":", 8) == 0 || + strncmp(mntfromname, ":", 8) == 0) { + mntfromname += 8; } - l = strlen(ent->f_mntfromname); + l = strlen(mntfromname); xo_emit("{:device}{P:/%s}{P:/%s}{P:/%s}", - ent->f_mntfromname, + mntfromname, l < 8 ? "\t" : "", l < 16 ? "\t" : "", l < 24 ? "\t" : " "); @@ -939,7 +939,7 @@ putfsent(struct statfs *ent) l < 8 ? "\t" : " "); free(opts); - if ((fst = getfsspec(ent->f_mntfromname))) + if ((fst = getfsspec(mntfromname))) xo_emit("{P:\t}{n:dump/%u}{P: }{n:pass/%u}\n", fst->fs_freq, fst->fs_passno); else if ((fst = getfsfile(ent->f_mntonname)))