[Bug 257960] mkimg: partition 1: No such file or directory when using a ":" in the file name

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 16 Apr 2026 06:07:02 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257960

--- Comment #5 from commit-hook@FreeBSD.org ---
A commit in branch main references this bug:

URL:
https://cgit.FreeBSD.org/src/commit/?id=50c1240ebfaf920ad12f05eb16d00f8b5b9d72e0

commit 50c1240ebfaf920ad12f05eb16d00f8b5b9d72e0
Author:     Aaditya Singh <aadityavksingh@gmail.com>
AuthorDate: 2026-02-21 18:13:54 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
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 <aadityavksingh@gmail.com>
    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(-)

-- 
You are receiving this mail because:
You are the assignee for the bug.