Skip to content

Commit

Permalink
pivot: split on any whitespace
Browse files Browse the repository at this point in the history
/proc/cmdline appends a '\n' at the end.  If the composefs= argument is
last on the commandline then we'll parse this \n as part of our
composefs= arg.  Splitting on any whitespace fixes this — the newline is
just another separator.
  • Loading branch information
allisonkarlitskaya committed Oct 28, 2024
1 parent 1e76d68 commit 379cef7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/bin/composefs-pivot-sysroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn parse_composefs_cmdline() -> Result<Sha256HashValue> {
let mut proc_cmdline = std::fs::File::open("/proc/cmdline")?;
proc_cmdline.read_to_end(&mut cmdline)?;
// TODO?: officially we need to understand quoting with double-quotes...
for part in cmdline.split(|c| *c == b' ') {
for part in cmdline.split(|c| c.is_ascii_whitespace()) {
if let Some(digest) = part.strip_prefix(b"composefs=") {
let mut value = [0; 32];
hex::decode_to_slice(digest, &mut value)?;
Expand Down

0 comments on commit 379cef7

Please sign in to comment.