On 2026-10-28T02:14:15, Enrique Hernández Bello <[email protected]> wrote:
> tools: mkimage: copy the FIT in process instead of shelling out to cp
>
> Rebuilding an existing FIT (-F) starts by making a working copy of it,
> and mkimage asks a shell to do that:
>
>         snprintf(cmd, sizeof(cmd), "cp \"%s\" \"%s\"",
>                  params->imagefile, tmpfile);
>
> so signing a FIT needs /bin/sh and cp on top of mkimage itself. That
> rules the tool out of the minimal images where firmware tends to be
> assembled; in one of them the failure reads
>
>     mkimage: system(cp "u-boot.itb" "u-boot.itb.tmp") failed:
>     No such file or directory
>
> which names cp but means there is no shell to run it with: glibc's
> system() uses posix_spawn and returns -1 with ENOENT when /bin/sh is
> missing.
>
> copyfile() does the same job in process, is declared in
> tools/fit_common.h and is already called further down this same
> function to restore the backup, so use it. Leaving cmd empty makes the
> existing "if (*cmd && ...)" guard skip system() altogether, the same
> way the auto-FIT path above already does.
>
> No functional change intended: the temporary file ends up with the
> same contents.
>
> Signed-off-by: Enrique Hernández Bello <[email protected]>
>
>  tools/fit_image.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <[email protected]>

Reply via email to