Skip to content

fix: pass paths to external commands as single arguments - #475

Merged
otavio merged 2 commits into
fix/wait-udev-after-mkfsfrom
fix/quote-command-arguments
Nov 21, 2026
Merged

otavio merged 2 commits into
fix/wait-udev-after-mkfsfrom
fix/quote-command-arguments

Conversation

@otavio

@otavio otavio commented Nov 21, 2026

Copy link
Copy Markdown
Member

Stacked on #473. Review only the last two commits; the base changes to master once #473 merges.

Summary

Commands run through easy_process are built as one string and split into arguments by its parser, so paths were not passed reliably:

  • A space split a path into several arguments, while the mount check had examined the intended path.
  • The parser is not sh: a backslash escapes even inside single quotes, and an unknown escape drops both characters, so /dev/disk\q1 reached mkfs as /dev/disk1, and udev's \x20 in by-label names was mangled.
  • Lossy UTF-8 conversion could name a different node than the one checked.

Commits:

  • fix(fs): quote the target device when formatting: adds shell_quote, which escapes backslashes and apostrophes and refuses non-UTF-8 with NonUtf8Path, and uses it for the format target.
  • fix(installer): quote paths passed to flash, ubifs and kobs-ng tools: the same for flash_erase/nandwrite/flashcp (previously Rust debug formatting), ubiupdatevol, kobs-ng and ubinfo.

Testing

  • cargo clippy -p updatehub --all-targets -- -D warnings and cargo test -p updatehub --lib pass on both commits (144 passed, 29 ignored).
  • New tests run the real parser through printf with an apostrophe and \x20, an embedded backslash and a trailing one, and check that non-UTF-8 is refused.
  • Not run: root/loop-device and MTD simulator tests.

- The format command is a string that easy_process splits into arguments, so a device path with
  spaces reached mkfs as several arguments while the mount check examined the intended path
- easy_process's parser is not sh: a backslash escapes even inside single quotes and an unknown
  escape drops both characters, so /dev/disk\q1 reached mkfs as /dev/disk1; escape backslashes
  and apostrophes
- A lossy UTF-8 conversion could hand mkfs a different node than the one checked, so non-UTF-8
  paths are refused with NonUtf8Path
- These commands are also built as strings and split into arguments, so paths with spaces or
  backslashes reached the tools altered; flash used Rust debug formatting, whose escapes are not
  what easy_process parses
- Quote targets, sources, chip paths and the ubinfo volume name with the helper used by format
@otavio
otavio added this pull request to stack #476 November 21, 2026 13:54
@otavio
otavio merged commit 223d907 into master Nov 21, 2026
3 checks passed
@otavio
otavio deleted the fix/quote-command-arguments branch November 21, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant