From nobody Mon Jun 30 13:34:19 2025 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 4bW6Zj1M3lz60Tfd; Mon, 30 Jun 2025 13:34:21 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bW6Zh5bm3z3sWV; Mon, 30 Jun 2025 13:34:20 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751290460; 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: in-reply-to:in-reply-to:references:references; bh=fg0sMVw4el/uZXTgJ7dZi0bfJe039YkzFBnilf/y/Ew=; b=sb6nF+KCRjWlRiJcDaJw5Vlw2VtWg5owa3WpsUxvzmd0CkhY3e0tEmEdCCjH53RZp4ypLj y5IeqQ670/bA+fgXseN4e3cU5R5rGCuz72dxOpUr0zZXIf+6B1v2VsMGY+Iq4agsgUO+gX kXWvZcwbfkJlFlJEzXVhEPiaufFkbLXeouQnyUVZ5KHMYcbp9QYx3dMJTkwa/r9+o/m5ZW wuPuczS+GwyHRwZbcTUv+ImBLPMUKwWHT/PETiGb9t2qM/avT+ySovTAa9MyL6rdE4EF/p /zxyzmEa1LK27QHC7XJh+gczRa2gYf0QIOAgLGYmHiHLh8IpU2Vs27yR4EQgxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751290460; 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: in-reply-to:in-reply-to:references:references; bh=fg0sMVw4el/uZXTgJ7dZi0bfJe039YkzFBnilf/y/Ew=; b=kpJmkadfcyZhuM9Qldtpb/h77UaSx0p5C1N+GUWD+PforL8RT2GKHHHAG7I3IehPhJw0Pm oXqcovPJ/4vLIovyA3yl+USm/vN8B6vfeHHh99OvphQD/Nv18Rnw1CiycvhWad0ISgIFwJ 1hmuuokXTIxnPKevwWY/1rLQ9HjIJ/MgfKW9UkL11av2hR9TpkQERAMsyQxibmh6H5oTR2 TmmP/yyRbm5ZzZwB0Z6imndIuFC5nZojAjHe+P496WC0IQUz8TJa+VytwcrejJ4PVdnC1g l7YBT8KrCMBCrX5GXpAdphdVEAZe0JxcYP3Gs8hz3z5lEYu9xmtywgu3bUu4KQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1751290460; a=rsa-sha256; cv=none; b=BVMmkgZYbH5q9AZsmHymnW6GNntuLG++zAVmaS5Z7KA1fCM4SvI3S9lluxmwLM1r0B+5Zd CiquQOYpWb2jhW1Lqk/fgIg45T0nmRj3iV+T0BshiYGjKoyywbLhgW/ceT+fN/ih28wFJe RQmZY+YYaHziIi7RANJ48W4TKY6WexgwV1oKAHAv87d0ceLwPr+nKWdDE4gh2ntc7Mhyb2 nr7HoyQx5hzKu8XPybR37ZROK6B4mScARAquERtdjHpULt53u3N6DqgiLVfqTGqD4JqdiL pUdeSpyiqFj1hWop4cFJNMuxBPI3fn5HbnDgQ/qAFXgBW+FydhvtG6w19pKjzw== Received: from [IPV6:2601:5c0:4200:b830:41cc:e0d8:c39:f14d] (unknown [IPv6:2601:5c0:4200:b830:41cc:e0d8:c39:f14d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4bW6Zh3JjTzQnm; Mon, 30 Jun 2025 13:34:20 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <69858708-8e73-4b70-9f33-5176fceb1b36@FreeBSD.org> Date: Mon, 30 Jun 2025 09:34:19 -0400 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: git: ad8d33679999 - main - mmc_xpt: use strlcpy instead of strncpy Content-Language: en-US To: Andriy Gapon , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202506270721.55R7LlB1067221@gitrepo.freebsd.org> From: John Baldwin In-Reply-To: <202506270721.55R7LlB1067221@gitrepo.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 6/27/25 03:21, Andriy Gapon wrote: > The branch main has been updated by avg: > > URL: https://cgit.FreeBSD.org/src/commit/?id=ad8d33679999c0e7f6fd2b77d2e414102bd365ec > > commit ad8d33679999c0e7f6fd2b77d2e414102bd365ec > Author: Andriy Gapon > AuthorDate: 2025-06-23 21:31:04 +0000 > Commit: Andriy Gapon > CommitDate: 2025-06-27 07:13:34 +0000 > > mmc_xpt: use strlcpy instead of strncpy > > A better practice in general. > > MFC after: 1 week > --- > sys/cam/mmc/mmc_xpt.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/sys/cam/mmc/mmc_xpt.c b/sys/cam/mmc/mmc_xpt.c > index 138f96eaaa49..4fce03004994 100644 > --- a/sys/cam/mmc/mmc_xpt.c > +++ b/sys/cam/mmc/mmc_xpt.c > @@ -1213,9 +1213,9 @@ mmc_path_inq(struct ccb_pathinq *cpi, const char *hba, > cpi->max_lun = 0; > cpi->initiator_id = 1; > cpi->maxio = maxio; > - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); > - strncpy(cpi->hba_vid, hba, HBA_IDLEN); > - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); > + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); > + strlcpy(cpi->hba_vid, hba, HBA_IDLEN); > + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); > cpi->unit_number = cam_sim_unit(sim); > cpi->bus_id = cam_sim_bus(sim); > cpi->protocol = PROTO_MMCSD; Hmm, are you sure these aren't depending on strncpy zero-padding the result out to the full length? String fields in inquiry/identity structures are often not C strings but have other requirements. (Some of them are space padded instead of \0 padded for example.) -- John Baldwin