From nobody Wed Oct 28 05:52:32 2026 X-Original-To: dev-commits-src-branches@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 4jDxN06ydhz6wrVG for ; Wed, 28 Oct 2026 05:52:32 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jDxN03zZbz4LT4 for ; Wed, 28 Oct 2026 05:52:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793166752; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ALxQI0pS7ZBm0PNO7vL93gSDaQACc+9LX+QFztFVGtM=; b=G9ml/2bvmMDl+/5simUoE6eOo761RIFNGj96SbgVaecrE8/MGVyULGZv7tKTfzHvOVYt1m nS8FmOwJPw0nSMTebr+5hkToELV3P/6YFLBtqCS0cyW2fXuSoPU/8SHeqVLpWjO6pxkJq1 j1rY1bzxCeULLTd530CZizSLPWhvVGO0CoMzo1GNmWwbbJ91Z3SzOEL92ucmltcff+cGwz lJicTaPUN9CVC3FIryYeSHzOBCCo2JRuNGZ0yow3op/st99RW/eVj3wzOhWQgnEpUTIek3 AtDcWN2btK6OWwtk0E+A8bxRtjhOpyWV2Hlu8rZRyEkI/U9QwlFTLollx15Q5g== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793166752; b=QHG3wp/sAnMdcAChEqSvH1V290iF29htceZsDCD980dhcZmwbVSfV/DrT+FVq458kEq+vS n4Ngn1xibojDt7/bLjjOEA0XnbNRztIstf+wn1/wNBcJSTd2RlrHeho6gMFKrP6UOunzyg JJP9kJSJSfsuaJ/+vhPPUk4uFMbwSbYWYd90daqTI8JYNyZhr3fiPsZcJiW/HeXl1LqRrf KIj5jUJa6T+sS/BxIwQN1cG5ank6LEZKcS4EuQsj9HbVpmuSyaMKkQt72MsXXuCoC6O0s7 plumahJy0VOwU50MSoc4HCMZn1MPWfxqpc5Ha+xCNGn/LbWZZU7TT7G9KtkzBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793166752; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ALxQI0pS7ZBm0PNO7vL93gSDaQACc+9LX+QFztFVGtM=; b=d3WxzI4JzpgxJBQRX66ux/cUAg4rIcOn8xzSllovzKOW4sz/eNtv3qwMHhzjMefaiZG8DT Gt7w1CyqubpSpJ5ZZ0zrpRvtMBwRN1ME8tUPs61YiH8OOZDfbT37NfZs05qnMB0NKF73XF f0Qn+sFktKZQXGKYVWinpsN3Gu6IUubhHyaQMrEI6wt67o79O6OnXRF4yKTeGg0C7k3onp Hyb2JyeTOtbksIvnMxVtACpdREKllxaszz5InNQ7DNm/2MsHaLUfb69e+by9WPfVyfA/0Q mQ2mdFfb2Cc6dwFG+iHQoDHRB4IoxSB2iz5eWvH3uPybfKDowrEPIUP3yi54ig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jDxN03dC8zvYl for ; Wed, 28 Oct 2026 05:52:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 33ef3 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 28 Oct 2026 05:52:32 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Aaditya Singh From: Colin Percival Subject: git: 8aaf8771e254 - stable/15 - mkimg: Fix parsing of filenames containing colons List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: Commits to the stable branches of the FreeBSD src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 8aaf8771e2543690d60aa0d008f250d151f450cb Auto-Submitted: auto-generated Date: Wed, 28 Oct 2026 05:52:32 +0000 Message-Id: <6ae18da0.33ef3.134cc958@gitrepo.freebsd.org> The branch stable/15 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=8aaf8771e2543690d60aa0d008f250d151f450cb commit 8aaf8771e2543690d60aa0d008f250d151f450cb Author: Aaditya Singh AuthorDate: 2026-02-21 18:13:54 +0000 Commit: Colin Percival CommitDate: 2026-10-28 01:11:42 +0000 mkimg: Fix parsing of filenames containing colons When using PART_KIND_FILE (-p type:=filename), mkimg uses a colon to separate an optional offset (e.g., filename:offset). strsep() was being used to split the string at the first colon. This caused failures when the filename itself contained a colon (e.g., "th:is"). This patch uses stat() to check if the entire string exists as a file. If so, use it directly without splitting. If the full string is not a valid file, fall back to splitting at the right-most colon using strrchr(). Uses errc() to fail and exit immediately when an existing directory is input instead of a file in PART_KIND_FILE mode. PR: 257960 Signed-off-by: Aaditya Singh Reviewed by: jlduran Pull Request: https://github.com/freebsd/freebsd-src/pull/2041 (cherry picked from commit 50c1240ebfaf920ad12f05eb16d00f8b5b9d72e0) --- usr.bin/mkimg/mkimg.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/usr.bin/mkimg/mkimg.c b/usr.bin/mkimg/mkimg.c index 03dd76943393..e814b67b1186 100644 --- a/usr.bin/mkimg/mkimg.c +++ b/usr.bin/mkimg/mkimg.c @@ -446,6 +446,8 @@ mkimg(void) { FILE *fp; struct part *part; + struct stat sb; + char *p; lba_t block, blkoffset; uint64_t bytesize, byteoffset; char *size, *offset; @@ -468,12 +470,28 @@ mkimg(void) /* Look for an offset. Set size too if we can. */ switch (part->kind) { case PART_KIND_SIZE: - case PART_KIND_FILE: offset = part->contents; size = strsep(&offset, ":"); - if (part->kind == PART_KIND_SIZE && - expand_number(size, &bytesize) == -1) + if (expand_number(size, &bytesize) == -1) error = errno; + break; + case PART_KIND_FILE: + size = part->contents; + if (stat(part->contents, &sb) == 0) { + if (S_ISDIR(sb.st_mode)) { + errc(EX_IOERR, EISDIR, "partition %d", + part->index + 1); + } + offset = NULL; + } else { + p = strrchr(part->contents, ':'); + if (p != NULL) { + *p = '\0'; + offset = p + 1; + } else { + offset = NULL; + } + } if (offset != NULL) { if (*offset != '+') abs_offset = true;