Repository navigation
fix: pass paths to external commands as single arguments - #475
Merged
Merged
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Commands run through
easy_processare built as one string and split into arguments by its parser, so paths were not passed reliably:/dev/disk\q1reachedmkfsas/dev/disk1, and udev's\x20in by-label names was mangled.Commits:
fix(fs): quote the target device when formatting: addsshell_quote, which escapes backslashes and apostrophes and refuses non-UTF-8 withNonUtf8Path, and uses it for theformattarget.fix(installer): quote paths passed to flash, ubifs and kobs-ng tools: the same forflash_erase/nandwrite/flashcp(previously Rust debug formatting),ubiupdatevol,kobs-ngandubinfo.Testing
cargo clippy -p updatehub --all-targets -- -D warningsandcargo test -p updatehub --libpass on both commits (144 passed, 29 ignored).printfwith an apostrophe and\x20, an embedded backslash and a trailing one, and check that non-UTF-8 is refused.