From 379cef78c5e18f858dd5fc79d54ae88feb8ecce3 Mon Sep 17 00:00:00 2001 From: Allison Karlitskaya Date: Mon, 28 Oct 2024 21:44:15 +0100 Subject: [PATCH] pivot: split on any whitespace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /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. --- src/bin/composefs-pivot-sysroot.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/composefs-pivot-sysroot.rs b/src/bin/composefs-pivot-sysroot.rs index 8f24733..7f61f6b 100644 --- a/src/bin/composefs-pivot-sysroot.rs +++ b/src/bin/composefs-pivot-sysroot.rs @@ -10,7 +10,7 @@ fn parse_composefs_cmdline() -> Result { 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)?;