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
This commit is contained in:
parent
52dd6b0b74
commit
9e497a4ce7
|
|
@ -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';
|
||||
|
|
|
|||
Loading…
Reference in New Issue