From nobody Mon May 13 19:04:21 2024 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 4VdTS538Rzz5Kn8N; Mon, 13 May 2024 19:04:21 +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 4VdTS518LSz4cmk; Mon, 13 May 2024 19:04:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715627061; 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=1IJn2po9PVz3XqSMJdsPvC/oq0ZvHRCSSRmmMXFd5SE=; b=AYvRvEhRq1WSG/jZOWn3p2TDwjD/45fPc45PhexINNnIOaLXA8DI0pxEnyjORWfGSX+81n p22ZyD4sNk6YP4dNQvb6mb2LVPynpnUmDJtXh6t/B3TmWus33tufnSqpfF4LQxdet6yW8+ SdiiXrbkUw4gMbEoaDtURTYZohb2PHaqJcaSCUGAkYZxw8OH61uf370OpPxFdyre6G5l3D MTG744IZ2QJ4AcSMZXoP0t5isyPw5Ly8W2X9hLxBHHpx1UjN+UvgWaZGpKe081L182stbj wmXw5zRcuf5o/KfyZYtqksIaNKPffLw1ziU53++0wMEM+0FapzonFKyo79YeBg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715627061; a=rsa-sha256; cv=none; b=W6aPP/97YJZcL/Rhuc2YeVSlfMlL6KXWDzRrbYcjAVqWVYbbSdEhAhsKUP103UKAaQRjV/ 9vm8Gp4cHIKKHdS/axMbKrh/0lxVIuoVVxXLFWKWh/If2egFeA7nQViNEYYuFdRn0Cu1KY rDDjf1+IePEK/pOEdqFvQmbli5Y8ZijLfVKYWqSkPgzTRBPC+rl220IbyTr5p9alTI7ps8 F5cePRevuruWJTE2uhA5ZGyQjCxFvLtKDfLFEgcMm6UDHm6whg71VE9YvdCB/qav3YxYoF ZQREhxcS+4GzQD0tGRRz4w/8Is6HTIahnnO6p9Yr8F0BdeSr4kVfJOwhCnJJAg== 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=1715627061; 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=1IJn2po9PVz3XqSMJdsPvC/oq0ZvHRCSSRmmMXFd5SE=; b=gyL6crXudt1rpyKQRVjVL+esOvh6/9KHaGEUcX0ygEYJlVLunV+bvIiBF1kbBqnq6B9KGm sIWdEifHO6+XfCl4vWZ836OjHWBrDMDSF8lXCkkk0BlbJ/i4h9stkUOhga+foGt3iXf7iz 35xBcCw7uRG7sGsIwDVmFXekLeaFZbqi6aTYPlzsMYVuBZnEDWbXDVTKiaJ6a0siwqn9dm a6syxZ0DrIN7t4DQqkUuKfBrc13odw11YIDrkOBf/LenATGP4mXNnsSk4hSNcqezzYQM4Z xT6xncCFWCjpFxhBATNQ/Epwtk+T1tjMJbVIhioU0SNSno6d7TYhrSqnlz0cvQ== 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 4VdTS50mfsz10Hm; Mon, 13 May 2024 19:04:21 +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 44DJ4LR3001318; Mon, 13 May 2024 19:04:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44DJ4Le0001315; Mon, 13 May 2024 19:04:21 GMT (envelope-from git) Date: Mon, 13 May 2024 19:04:21 GMT Message-Id: <202405131904.44DJ4Le0001315@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: da4230af3fda - main - nvme/f: Use strlcpy instead of strncpy + manual string termination 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: da4230af3fda2d4d1898124689f2e07b1450876d Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=da4230af3fda2d4d1898124689f2e07b1450876d commit da4230af3fda2d4d1898124689f2e07b1450876d Author: John Baldwin AuthorDate: 2024-05-13 19:04:03 +0000 Commit: John Baldwin CommitDate: 2024-05-13 19:04:03 +0000 nvme/f: Use strlcpy instead of strncpy + manual string termination Reviewed by: dab, imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D45153 --- sys/dev/nvme/nvme_ctrlr.c | 3 +-- sys/dev/nvme/nvme_ns.c | 3 +-- sys/dev/nvmf/host/nvmf.c | 3 +-- sys/dev/nvmf/host/nvmf_ns.c | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c index b7b03082c54e..00e619bfdc46 100644 --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -1334,9 +1334,8 @@ nvme_ctrlr_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int flag, case NVME_GET_NSID: { struct nvme_get_nsid *gnsid = (struct nvme_get_nsid *)arg; - strncpy(gnsid->cdev, device_get_nameunit(ctrlr->dev), + strlcpy(gnsid->cdev, device_get_nameunit(ctrlr->dev), sizeof(gnsid->cdev)); - gnsid->cdev[sizeof(gnsid->cdev) - 1] = '\0'; gnsid->nsid = 0; break; } diff --git a/sys/dev/nvme/nvme_ns.c b/sys/dev/nvme/nvme_ns.c index 360b9f982c20..e494b8cd857a 100644 --- a/sys/dev/nvme/nvme_ns.c +++ b/sys/dev/nvme/nvme_ns.c @@ -82,9 +82,8 @@ nvme_ns_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int flag, case NVME_GET_NSID: { struct nvme_get_nsid *gnsid = (struct nvme_get_nsid *)arg; - strncpy(gnsid->cdev, device_get_nameunit(ctrlr->dev), + strlcpy(gnsid->cdev, device_get_nameunit(ctrlr->dev), sizeof(gnsid->cdev)); - gnsid->cdev[sizeof(gnsid->cdev) - 1] = '\0'; gnsid->nsid = ns->id; break; } diff --git a/sys/dev/nvmf/host/nvmf.c b/sys/dev/nvmf/host/nvmf.c index 0902bc78a7b5..e43d438aaa8c 100644 --- a/sys/dev/nvmf/host/nvmf.c +++ b/sys/dev/nvmf/host/nvmf.c @@ -872,9 +872,8 @@ nvmf_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int flag, return (nvmf_passthrough_cmd(sc, pt, true)); case NVME_GET_NSID: gnsid = (struct nvme_get_nsid *)arg; - strncpy(gnsid->cdev, device_get_nameunit(sc->dev), + strlcpy(gnsid->cdev, device_get_nameunit(sc->dev), sizeof(gnsid->cdev)); - gnsid->cdev[sizeof(gnsid->cdev) - 1] = '\0'; gnsid->nsid = 0; return (0); case NVME_GET_MAX_XFER_SIZE: diff --git a/sys/dev/nvmf/host/nvmf_ns.c b/sys/dev/nvmf/host/nvmf_ns.c index 3ce434bf7c50..3428cbadc974 100644 --- a/sys/dev/nvmf/host/nvmf_ns.c +++ b/sys/dev/nvmf/host/nvmf_ns.c @@ -258,9 +258,8 @@ nvmf_ns_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, return (nvmf_passthrough_cmd(ns->sc, pt, false)); case NVME_GET_NSID: gnsid = (struct nvme_get_nsid *)arg; - strncpy(gnsid->cdev, device_get_nameunit(ns->sc->dev), + strlcpy(gnsid->cdev, device_get_nameunit(ns->sc->dev), sizeof(gnsid->cdev)); - gnsid->cdev[sizeof(gnsid->cdev) - 1] = '\0'; gnsid->nsid = ns->id; return (0); case DIOCGMEDIASIZE: