[ostree] prepare-root: Fix ostree= kernel argument at end
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] prepare-root: Fix ostree= kernel argument at end
- Date: Mon, 2 Sep 2013 17:27:56 +0000 (UTC)
commit 9e497a4ce7cfde5db9605353590c1fe037f969ac
Author: Colin Walters <walters verbum org>
Date: Sun Sep 1 04:16:52 2013 -0400
prepare-root: Fix ostree= kernel argument at end
Extracting the code for parse_ostree_cmdline() and running it on some
test input (on RHEL6.4 glibc), I can reproduce the odd behavior from
getline() where it apparently returns the size of the default malloc
buffer in the size output, and some non-zero value.
This behavior would be OK except that it breaks the logic for
stripping off the trailing newline, which in turn breaks booting
because we return "ostree=foo\n".
This has worked so far in gnome-ostree because syslinux apparently
injects initrd=/path/to/initrd as a final kernel argment.
Anyways, we don't handle NUL characters here in /proc/cmdline, so
let's just call strlen () to be safe.
https://bugzilla.gnome.org/show_bug.cgi?id=707192
src/switchroot/ostree-prepare-root.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c
index a77da7c..25ac66b 100644
--- a/src/switchroot/ostree-prepare-root.c
+++ b/src/switchroot/ostree-prepare-root.c
@@ -54,8 +54,15 @@ parse_ostree_cmdline (void)
if (!f)
return NULL;
+ /* Note that /proc/cmdline will not end in a newline, so getline
+ * will fail unelss we provide a length.
+ */
if (getline (&cmdline, &len, f) < 0)
return NULL;
+ /* ... but the length will be the size of the malloc buffer, not
+ * strlen(). Fix that.
+ */
+ len = strlen (cmdline);
if (cmdline[len-1] == '\n')
cmdline[len-1] = '\0';
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]