From nobody Thu Apr 16 06:06:34 2026 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 4fx6wB4ljJz6Z0k7 for ; Thu, 16 Apr 2026 06:06:34 +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 "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fx6wB1g1Wz3jcd for ; Thu, 16 Apr 2026 06:06:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776319594; 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=ISwrOycC9pIvbHMco7jIp2MtYfdP9hl1B6b1FjxfWis=; b=Q+v+g84XFBC/NO+SAsNp3bXWPsawzBNhfA8B5Lzaj83Fnuws/f2o4A9yil8sDLqfFlBxHU 1cEdYgVs+4vMHseNJAjP9SJI2gzXYL9bjqImE11DivVXlTMdQppo58i88+6AWsxk7XYlIV xFmEbv1JzceY5h6JOSLmcA4yZ4myoAcIb291i3jZoou+hKxLQpbE4wcoz9ZdzehWfN5FI0 LbtLkrvPLrinNBzh6f+KEteDaHUcf1x/UEYHb6KqZJtNPFFyW96NFKGykK9SqGFEwpsDnk hfvCNEnf98gH8xiGdQgLn/zRueExGCLF8FUnBoqq7XmKiVJdY7m4mAoQ6S+D9w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1776319594; a=rsa-sha256; cv=none; b=WpggWqoFXYZKMl6e5Ho67dQ2mjAADEFeekGxSc/KRHCUYr+atiYiL93EJccmJsqd8N6UtY y0Go79IKRAzakyN1UuPEZavgwmQTmbpLBoXK1SSyhexpNMIwGrNc9p6JvxFDMJ0lV/NYrb 88e9x6tCTJmAFRQCy3KZ76f+BTEL0Kg7N7PlyAZykhe4RAu4nYhhAP6BaFtb5v7y/phs6N URxOqA3SVo3Dtt/LOFRSuq7ZPeT/fAOVgofNZYWDcEAiA4IeG5F3yILaJ3nP2BBH4l+vGi pN8Zql2W9fdwqyMH9aiDK0IAyHl2TKzEWQ/ew2khGmRPmGm30quTdGKtCGGmdw== 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=1776319594; 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=ISwrOycC9pIvbHMco7jIp2MtYfdP9hl1B6b1FjxfWis=; b=k3Umz6GLsfq2ahhnN6OJpj46YVeWedkxrBYdUat+I8njifealJeU+div0Ax8fRrCx3pRhX INZYghi0SNNvudVCu6z6pbcKE9YRR46C+Qe2JsuzGnbzvI/O6U/qu0dyiCrW1k6S4TD8tw JLcQB6qWdl+eSiNcXXzAo3w95DV0e02auZHhOkd+GqAl6zDBl9eZbPyS/zqBvy2XMqdKjt SnNozqSiwxPLLFCEQwTC4U9tUGL0ViabF7Wx8HyFn5XBv0rbEgdRtrkCUKjkEJcMafNYn/ IZnMzNiy3PYx3/Ajs23u8py6NsWSnTOaczjmPs51v9ZVBuHT2VYBM4wNm/myyw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fx6wB1DTBzvSB for ; Thu, 16 Apr 2026 06:06:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3d8c9 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 16 Apr 2026 06:06:34 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Aaditya Singh From: Warner Losh Subject: git: 50c1240ebfaf - main - mkimg: Fix parsing of filenames containing colons 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 50c1240ebfaf920ad12f05eb16d00f8b5b9d72e0 Auto-Submitted: auto-generated Date: Thu, 16 Apr 2026 06:06:34 +0000 Message-Id: <69e07c6a.3d8c9.1f3f9d13@gitrepo.freebsd.org> The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=50c1240ebfaf920ad12f05eb16d00f8b5b9d72e0 commit 50c1240ebfaf920ad12f05eb16d00f8b5b9d72e0 Author: Aaditya Singh AuthorDate: 2026-02-21 18:13:54 +0000 Commit: Warner Losh CommitDate: 2026-04-16 06:05:21 +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 --- 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 c625b49dc29a..4a288d66be81 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;