From 155a29d9b336b1d331f163e3a859772dd041b388 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Fri, 3 Nov 2023 20:49:24 +0000 Subject: [PATCH] preinit: strip trailing newline(s) on /proc/cmdline --- pkgs/preinit/preinit.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/preinit/preinit.c b/pkgs/preinit/preinit.c index 227113a..f36f4a0 100644 --- a/pkgs/preinit/preinit.c +++ b/pkgs/preinit/preinit.c @@ -50,8 +50,13 @@ int main(int argc, char *argv[], char *envp[]) if(cmdline>=0) { int len = read(cmdline, buf, sizeof buf - 1); buf[len]='\0'; - write(1, "cmdline ", 8); + while(buf[len-1]=='\n') { + buf[len-1]='\0'; + len--; + } + write(1, "cmdline: \"", 10); write(1, buf, len); + write(1, "\"\n", 2); }; parseopts(buf, &rootdevice, &rootfstype);