From nobody Thu Jan 26 01:01:41 2023 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 4P2Mq96cHGz30t93; Thu, 26 Jan 2023 01:01:41 +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 4P2Mq967qNz4YLB; Thu, 26 Jan 2023 01:01:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674694901; 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=e9/g384abHZUED2kUwaZDL/h8spdQAPDAQZqlVJ0XtQ=; b=v9jueqkgQYe7IEvSWOvuc4242SSamXa8b3TTWdvz62MV0OBSMP4eRxkHzX/7OoRpkStjNr Rue82QtjgdOswapwJ0tWyLcbVgCK5wJvjvQsCvh/dkZqKV9sfocXCzncEeyNXrLIQkUspQ Dd3IxKZc9NNhFb3ernWlSOQyq8kw1QjoZMoOSc6/Rm2wH1XgnNmDW/YWchXS/xuNeiPaM/ ZUYoT+u9oFBU265tJ3Uu44V+++f5Bfng1+0O2g9gkNWVhMa4TVl76QzQBPaLQ9waDA8HzN 6vqTMPaKs2vlYsg2KmME6K24lt3sBDM0CwcKalP0aluEbibyHmt6JFEVRjV6Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674694901; 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=e9/g384abHZUED2kUwaZDL/h8spdQAPDAQZqlVJ0XtQ=; b=CiXJd3FDe75ouMno5WhZTvbKMpBv6YhsFUSsfTyvryRkLfjr3aZslQJsaHAdORofDFFd+1 uS4nP3FlYqDv3xLjn2OBaRyhUCTnHPpUV/Npape58/Q9/cI5zlIvwgh86otgDW6YhlRHUM Nkrv7/LDxxdn26Jb59deEfw5+q6E11WDiAUvRnGZ9qQsr7/plPZZXR6Yhvtnx7NtFP6fSg osdP2fPtpcsQgqtWgjFYq+Xz4YkLZ/RrG9u7313LMgb57pW06S7tssDfcrv/rMUw/VKrka //6iGGjcC/KBGTT/e+/IsNTV5u7/AWjdHRKzxF+aCmr/jfrNjpyXwnrSIo+1Hg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674694901; a=rsa-sha256; cv=none; b=cFvF+szKHxiQdV4qrWyH0iZZMGNbVTfSSyW7ANB85uTDCwtNZyN0bWDF3Ivhv1KdwapWCL F0wI0oLmwqi8weoATT1mA/gCr7yqnNY99KMNACir8n3U155HS+xtf8yfvRCrbYf3U1nJiH bjqfn+0/CdB2tArBWwTZ2Az8MjZZIXcE9pWCQ058xhduqt/L+1fGsZYgREeGWSiJ0/Ftkn i5R1ZXBhyBwWDTSb5mlUJOo/l77ofQiaQ7lPpbz7nW1tuRHG66Kx8Si0wKQmZi3yYYlrdI DDXbsT1k56c30Nwzi8FfYyyNcDknF/xmdhA+JvtqGO/bkx3WuP5YMre0CEaqOA== 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 4P2Mq95CcTz18y2; Thu, 26 Jan 2023 01:01:41 +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 30Q11fqn007970; Thu, 26 Jan 2023 01:01:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30Q11fDP007969; Thu, 26 Jan 2023 01:01:41 GMT (envelope-from git) Date: Thu, 26 Jan 2023 01:01:41 GMT Message-Id: <202301260101.30Q11fDP007969@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kirk McKusick Subject: git: 0bd4c448ec1d - main - Rewrite to avoid Coverity false positive. 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0bd4c448ec1dfdc2300a6cacca42e1fc7c4d8f14 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=0bd4c448ec1dfdc2300a6cacca42e1fc7c4d8f14 commit 0bd4c448ec1dfdc2300a6cacca42e1fc7c4d8f14 Author: Kirk McKusick AuthorDate: 2023-01-26 00:57:26 +0000 Commit: Kirk McKusick CommitDate: 2023-01-26 00:57:26 +0000 Rewrite to avoid Coverity false positive. MFC after: 1 week Reported by: Coverity (CID 1502669) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D37907 --- sbin/mount/getmntopts.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sbin/mount/getmntopts.c b/sbin/mount/getmntopts.c index e6607c385341..7702da903749 100644 --- a/sbin/mount/getmntopts.c +++ b/sbin/mount/getmntopts.c @@ -166,6 +166,7 @@ getmntpoint(const char *name) char *ddevname; struct statfs *mntbuf, *statfsp; int i, mntsize, isdev; + u_long len; if (stat(name, &devstat) != 0) return (NULL); @@ -178,12 +179,13 @@ getmntpoint(const char *name) statfsp = &mntbuf[i]; ddevname = statfsp->f_mntfromname; if (*ddevname != '/') { - if (strlen(_PATH_DEV) + strlen(ddevname) + 1 > - sizeof(statfsp->f_mntfromname)) + if ((len = strlen(_PATH_DEV) + strlen(ddevname) + 1) > + sizeof(statfsp->f_mntfromname) || + len > sizeof(device)) continue; - strcpy(device, _PATH_DEV); - strcat(device, ddevname); - strcpy(statfsp->f_mntfromname, device); + strncpy(device, _PATH_DEV, len); + strncat(device, ddevname, len); + strncpy(statfsp->f_mntfromname, device, len); } if (isdev == 0) { if (strcmp(name, statfsp->f_mntonname))