From nobody Wed Jan 15 02:33:42 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 4YXqn246HGz5kmSf; Wed, 15 Jan 2025 02:33:42 +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 4YXqn23C1kz3fkB; Wed, 15 Jan 2025 02:33:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736908422; 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=hLrxx6wYvj1OfvC/pA6chO/ITlSIjzOyoYmtZ4i3yPI=; b=PDgzeLQn78PTVVR8yOLcCU+c+hqZPSFXaq547xTh9sDPkheecvWUhbRH7gK2GkN0YJOjP7 QnJ9DpGsH7+XLWxYixCuksdAdfHl3G3gOzY/OqhQ0VM6y47hf/0MV3nmRudvpoDiiIcVFo eNNToK6oS6bj2LuonxXpnTdRLhBjide3Y8s1+F0QlMSNRzH3HzSXqu6aqR4e/OHfhzftMX HN4sDti/eiYOUAinOauWjhNf+ZnNX3PG26CeKZ8O+du/TxMwftOcJKJO4f46km3YOdTvPl CucC+hfMgVWrVJ+pMA/1jCQryEpH5Z2gs0toV4qsitELjRGGBaBNX8XsQ8etmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736908422; 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=hLrxx6wYvj1OfvC/pA6chO/ITlSIjzOyoYmtZ4i3yPI=; b=NbMDCUgApeMha6ZE5e044p3II25eNtgWG+EjTcwje9KBaWLwKOh3yUlxIiBfXfadxWuIuP uAvxdls7MK8tPOe5jltclL+zAIls61eCrL+kS6KmlaV/bwQSRHC94KknAiBXtnwtzVcRK5 yLne3IcuaAFcQ31WVLJieT7BX5UiEltWwVlgUg1YGz8xgWOLIYhtdwx8GEaMGKxzAzXodT X11T0n5qxOdAMP9ES1is70+Iutq7ib4H1p+uxa0+57/fysTl/JK8G5zDCxsXVSLm9fS4Cj 5SlKIIoKfjNTMStfYOILTw6amlyHTwunMzk6vVO880tu4uxv9hElBl8NwV0iNw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736908422; a=rsa-sha256; cv=none; b=fMxyFiXgg7khYvFNiFc/rCjZezFrdaROCaJ/FFFz25wH189NSVJujtDUE0CVJQJG+8RHkO MMIUPfftDVOPXYenTLJoS0SPAsqSx8Kz+EOlpBuW8PueDNgNsW9SngoY6x4sssGhkjZYo4 hVS5LmnNsFzrEUkm4Q5jdegYm8IkjsDbly/AXhB1wZsRL7m+kjY2TwBjWUJgLGgHvUk7Rs cN8hI43v/RVMrmR52dQidP+qCOR4h5+fH/55j+swNO+MK7f3OSA3o0NLLAVeaC2FgIiB1R 03M4jW/U2vRIZvGicun08rGVA+tyYf9wun6ko17gakYBv8PuwJ9z9JL8SWbMZg== 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 4YXqn22Y51zBy7; Wed, 15 Jan 2025 02:33:42 +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 50F2XgBw046453; Wed, 15 Jan 2025 02:33:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50F2XgsP046450; Wed, 15 Jan 2025 02:33:42 GMT (envelope-from git) Date: Wed, 15 Jan 2025 02:33:42 GMT Message-Id: <202501150233.50F2XgsP046450@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 954de313b261 - stable/13 - makefs: Crudely fix a sprintf warning 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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 954de313b261f6e631ca1a29106ae47e5621479c Auto-Submitted: auto-generated The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=954de313b261f6e631ca1a29106ae47e5621479c commit 954de313b261f6e631ca1a29106ae47e5621479c Author: Ed Maste AuthorDate: 2024-12-22 16:00:49 +0000 Commit: Ed Maste CommitDate: 2025-01-15 02:33:30 +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 (cherry picked from commit 2069f6ecb1b1268deac980176c652ffab264970e) (cherry picked from commit fb0239e69f17400b08421a002a72b9520afd8285) --- 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 7ce9a3b6cbb2..e895f09bef0f 100644 --- a/usr.sbin/makefs/cd9660.c +++ b/usr.sbin/makefs/cd9660.c @@ -142,10 +142,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 @@ -225,7 +226,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; @@ -806,7 +808,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)) @@ -1109,7 +1111,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; @@ -1575,7 +1579,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 @@ -1586,6 +1590,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 */ @@ -1627,7 +1632,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; } @@ -1635,7 +1640,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 @@ -1649,6 +1654,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 */ @@ -1694,7 +1700,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; } @@ -1709,15 +1715,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(); } @@ -1929,7 +1935,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;