]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
main: fix incorrectly sized buffer for /proc/cmdline
authorRay Strode <rstrode@redhat.com>
Fri, 10 Oct 2014 20:11:01 +0000 (16:11 -0400)
committerRay Strode <rstrode@redhat.com>
Fri, 10 Oct 2014 20:12:55 +0000 (16:12 -0400)
We assume /proc/cmdline will be no more than 512 bytes (including NUL).
It can actually be 4096 bytes (excluding NUL).

This commit makes sure we allocate enough space for it and its NUL.

src/main.c

index dce2f9fd5d3cb5eeecc93659783836adba78e099..d78ee1335cd7f9dc53636b79ab5c755385b6bf33 100644 (file)
@@ -57,7 +57,7 @@
 #include "ply-progress.h"
 
 #ifndef PLY_MAX_COMMAND_LINE_SIZE
-#define PLY_MAX_COMMAND_LINE_SIZE 512
+#define PLY_MAX_COMMAND_LINE_SIZE 4097
 #endif
 
 #define BOOT_DURATION_FILE     PLYMOUTH_TIME_DIRECTORY "/boot-duration"
@@ -1703,7 +1703,7 @@ get_kernel_command_line (state_t *state)
         }
 
         ply_trace ("reading kernel command line");
-        if (read (fd, state->kernel_command_line, sizeof(state->kernel_command_line)) < 0) {
+        if (read (fd, state->kernel_command_line, sizeof(state->kernel_command_line) - 1) < 0) {
                 ply_trace ("couldn't read it: %m");
                 close (fd);
                 return false;