From nobody Mon Dec 23 15:30:51 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 4YH26M1zKmz5Wq8w; Mon, 23 Dec 2024 15:30:51 +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 4YH26M1XHQz4hWl; Mon, 23 Dec 2024 15:30:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734967851; 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=tz5uG5NfQ+O6QogSOplcpVtHWqPpsBbzgYt0lbr3Als=; b=OFHGGhI7KtwQr6sVzoCJXY4nT4eF5kou3V9hxB0LaTjuAsMAiRov9QsnddEpTbjCsB3l8/ ifww/8j313dblPJuolTxYwmBjwJXEn5Gsp3mO5HNYr/CVafsl2wFfLUEgVD88PJ+uO58mF dNeqp6UspbokB1yABTRfPpAJ194DA/SZojS5GwmYg+ksbnhl9muqEZvMpEooyP7u6e+tS2 WU3O8O0HiEzuaQo4JE3kt90HhbzdC8/N5dcuxMpdkYusOOLGZj/q1LsplYI/Lgyp02HAIH 7beVmbD41dyKmFx2Yui2S5OwRolNxMKLxGy2YuwppbVd34T6gN9CT48MSlP3AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734967851; 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=tz5uG5NfQ+O6QogSOplcpVtHWqPpsBbzgYt0lbr3Als=; b=xLFdTHemXzfYwlpVUyVtSY6DWXdX5EzwiqkW/IUo7X8FmVwM5ALvEpz7OZyqiRwgKwy9HN gEVTVREWLiEnf6CBJu8jBDFVBC4rSSkpUIbg19CASuri30HBJ+ixlK5Hm54zDhj5ab1gJW CKCIbXdI7tGZ7BOP+7ah/9VPl/UwcSRibsO7ixPhYLuaDAQWbrI+7dQl7z+0eN/or+SAh9 FgJMnPsVbNHxG9on631gntM38TqihftqmCwrO4L6mW5kmKcGnLatgnd1pkdfDz7SEXY3Ib PuMCqAgBOwPyi746bA1siB7vs1k4OkaK73Z2OuHkL7QDqJDC/Orc4feXP7Smng== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734967851; a=rsa-sha256; cv=none; b=xxo7IEtyQCG6cVKfGT3ebPinSEq0w/+tEIcp5IsczrSwBHt9Kfnu4EWsWvO8w0xnq5htrr 17gRImMpXeYEEL/IGmCLYlO13Pw6mgaNsAYWLC06HfMZmLHlrzmqtsQgGAtnu3Dn8lDCik MA9je9OUTScbS5I6jLmKn8JFkLPD8X8U9EHuWIkuLc7zcQiwEy+DlbaDB3fyW29SVNUIBq XMHnhvCJBODnVVfPclZW4/+v/H2F6a0GhtGki/qfcuqZHYceTUHxy8LdClFeUIGMRjRNvp 6UVc9pVeDlMj/pU75jzpivSew8coFyIFP0FvBvxnTenc7pQ2NI+mAASQon2jrA== 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 4YH26M18XJzycN; Mon, 23 Dec 2024 15:30:51 +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 4BNFUp33082032; Mon, 23 Dec 2024 15:30:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BNFUpRp082029; Mon, 23 Dec 2024 15:30:51 GMT (envelope-from git) Date: Mon, 23 Dec 2024 15:30:51 GMT Message-Id: <202412231530.4BNFUpRp082029@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 2069f6ecb1b1 - main - makefs: Crudely fix a sprintf warning 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: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2069f6ecb1b1268deac980176c652ffab264970e Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=2069f6ecb1b1268deac980176c652ffab264970e commit 2069f6ecb1b1268deac980176c652ffab264970e Author: Ed Maste AuthorDate: 2024-12-22 16:00:49 +0000 Commit: Ed Maste CommitDate: 2024-12-23 15:30:03 +0000 makefs: Crudely fix a sprintf warning Reviewed by: kevans Obtained from: OpenBSD d95291fdb2dc Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48178 --- usr.sbin/makefs/cd9660.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/usr.sbin/makefs/cd9660.c b/usr.sbin/makefs/cd9660.c index 500e3c08c7af..19bd6e0d21b0 100644 --- a/usr.sbin/makefs/cd9660.c +++ b/usr.sbin/makefs/cd9660.c @@ -140,10 +140,11 @@ static void cd9660_convert_structure(iso9660_disk *, fsnode *, cd9660node *, int static void cd9660_free_structure(cd9660node *); static int cd9660_generate_path_table(iso9660_disk *); static int cd9660_level1_convert_filename(iso9660_disk *, const char *, char *, - int); + size_t, int); static int cd9660_level2_convert_filename(iso9660_disk *, const char *, char *, + size_t, int); +static int cd9660_convert_filename(iso9660_disk *, const char *, char *, size_t, int); -static int cd9660_convert_filename(iso9660_disk *, const char *, char *, int); static void cd9660_populate_dot_records(iso9660_disk *, cd9660node *); static int64_t cd9660_compute_offsets(iso9660_disk *, cd9660node *, int64_t); #if 0 @@ -222,7 +223,8 @@ cd9660_set_defaults(iso9660_disk *diskStructure) memset(diskStructure->primaryDescriptor.abstract_file_id, 0x20,37); memset(diskStructure->primaryDescriptor.bibliographic_file_id, 0x20,37); - strcpy(diskStructure->primaryDescriptor.system_id, "FreeBSD"); + strlcpy(diskStructure->primaryDescriptor.system_id, "FreeBSD", + sizeof(diskStructure->primaryDescriptor.system_id)); /* Boot support: Initially disabled */ diskStructure->has_generic_bootimage = 0; @@ -797,7 +799,7 @@ cd9660_translate_node_common(iso9660_disk *diskStructure, cd9660node *newnode) memset(temp, 0, ISO_FILENAME_MAXLENGTH_WITH_PADDING); (void)cd9660_convert_filename(diskStructure, newnode->node->name, - temp, !(S_ISDIR(newnode->node->type))); + temp, sizeof(temp), !(S_ISDIR(newnode->node->type))); flag = ISO_FLAG_CLEAR; if (S_ISDIR(newnode->node->type)) @@ -1100,7 +1102,9 @@ cd9660_rename_filename(iso9660_disk *diskStructure, cd9660node *iter, int num, while (digits > 0) { digit = (int)(temp / powers); temp = temp - digit * powers; - sprintf(&tmp[numbts] , "%d", digit); + snprintf(&tmp[numbts], + ISO_FILENAME_MAXLENGTH_WITH_PADDING - numbts, + "%d", digit); digits--; numbts++; powers = powers / 10; @@ -1566,7 +1570,7 @@ cd9660_compute_full_filename(cd9660node *node, char *buf) */ static int cd9660_level1_convert_filename(iso9660_disk *diskStructure, const char *oldname, - char *newname, int is_file) + char *newname, size_t newnamelen, int is_file) { /* * ISO 9660 : 10.1 @@ -1577,6 +1581,7 @@ cd9660_level1_convert_filename(iso9660_disk *diskStructure, const char *oldname, int namelen = 0; int extlen = 0; int found_ext = 0; + char *orignewname = newname; while (*oldname != '\0' && extlen < 3) { /* Handle period first, as it is special */ @@ -1613,7 +1618,7 @@ cd9660_level1_convert_filename(iso9660_disk *diskStructure, const char *oldname, if (!found_ext && !diskStructure->omit_trailing_period) *newname++ = '.'; /* Add version */ - sprintf(newname, ";%i", 1); + snprintf(newname, newnamelen - (newname - orignewname), ";%i", 1); } return namelen + extlen + found_ext; } @@ -1621,7 +1626,7 @@ cd9660_level1_convert_filename(iso9660_disk *diskStructure, const char *oldname, /* XXX bounds checking! */ static int cd9660_level2_convert_filename(iso9660_disk *diskStructure, const char *oldname, - char *newname, int is_file) + char *newname, size_t newnamelen, int is_file) { /* * ISO 9660 : 7.5.1 @@ -1635,6 +1640,7 @@ cd9660_level2_convert_filename(iso9660_disk *diskStructure, const char *oldname, int namelen = 0; int extlen = 0; int found_ext = 0; + char *orignewname = newname; while (*oldname != '\0' && namelen + extlen < 30) { /* Handle period first, as it is special */ @@ -1675,7 +1681,7 @@ cd9660_level2_convert_filename(iso9660_disk *diskStructure, const char *oldname, if (!found_ext && !diskStructure->omit_trailing_period) *newname++ = '.'; /* Add version */ - sprintf(newname, ";%i", 1); + snprintf(newname, newnamelen - (newname - orignewname), ";%i", 1); } return namelen + extlen + found_ext; } @@ -1690,15 +1696,15 @@ cd9660_level2_convert_filename(iso9660_disk *diskStructure, const char *oldname, */ static int cd9660_convert_filename(iso9660_disk *diskStructure, const char *oldname, - char *newname, int is_file) + char *newname, size_t newnamelen, int is_file) { assert(1 <= diskStructure->isoLevel && diskStructure->isoLevel <= 2); if (diskStructure->isoLevel == 1) return(cd9660_level1_convert_filename(diskStructure, - oldname, newname, is_file)); + oldname, newname, newnamelen, is_file)); else if (diskStructure->isoLevel == 2) return (cd9660_level2_convert_filename(diskStructure, - oldname, newname, is_file)); + oldname, newname, newnamelen, is_file)); abort(); } @@ -1910,7 +1916,7 @@ cd9660_create_virtual_entry(iso9660_disk *diskStructure, const char *name, temp->isoDirRecord = emalloc(sizeof(*temp->isoDirRecord)); cd9660_convert_filename(diskStructure, tfsnode->name, - temp->isoDirRecord->name, file); + temp->isoDirRecord->name, sizeof(temp->isoDirRecord->name), file); temp->node = tfsnode; temp->parent = parent;