use slurp_proc_file() in get_command_line()
Resolves: bz2060824 Upstream: git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git Conflicts: None commit d6516ba4c88f217fe14455db92c60cd0e9af18f8 Author: Sven Schnelle <svens@linux.ibm.com> Date: Thu Dec 16 12:43:55 2021 +0100 use slurp_proc_file() in get_command_line() This way the size of the command line that get_command_line() can handle is no longer fixed. Signed-off-by: Sven Schnelle <svens@linux.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Philipp Rudo <prudo@redhat.com>
This commit is contained in:
parent
9e3d3bc043
commit
1ac74b6d66
@ -0,0 +1,52 @@
|
|||||||
|
commit d6516ba4c88f217fe14455db92c60cd0e9af18f8
|
||||||
|
Author: Sven Schnelle <svens@linux.ibm.com>
|
||||||
|
Date: Thu Dec 16 12:43:55 2021 +0100
|
||||||
|
|
||||||
|
use slurp_proc_file() in get_command_line()
|
||||||
|
|
||||||
|
This way the size of the command line that get_command_line() can handle
|
||||||
|
is no longer fixed.
|
||||||
|
|
||||||
|
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
|
||||||
|
Signed-off-by: Simon Horman <horms@verge.net.au>
|
||||||
|
|
||||||
|
diff --git a/kexec/kexec.c b/kexec/kexec.c
|
||||||
|
index f3adac517161d448552a16fd79488c1df100d356..7e4787bc821107b7af66ebdbcfc31f4e7e1d48cd 100644
|
||||||
|
--- a/kexec/kexec.c
|
||||||
|
+++ b/kexec/kexec.c
|
||||||
|
@@ -1172,25 +1172,19 @@ static char *slurp_proc_file(const char *filename, size_t *len)
|
||||||
|
*/
|
||||||
|
char *get_command_line(void)
|
||||||
|
{
|
||||||
|
- FILE *fp;
|
||||||
|
- char *line;
|
||||||
|
- const int sizeof_line = 2048;
|
||||||
|
-
|
||||||
|
- line = malloc(sizeof_line);
|
||||||
|
- if (line == NULL)
|
||||||
|
- die("Could not allocate memory to read /proc/cmdline.");
|
||||||
|
-
|
||||||
|
- fp = fopen("/proc/cmdline", "r");
|
||||||
|
- if (!fp)
|
||||||
|
- die("Could not open /proc/cmdline.");
|
||||||
|
-
|
||||||
|
- if (fgets(line, sizeof_line, fp) == NULL)
|
||||||
|
- die("Can't read /proc/cmdline.");
|
||||||
|
+ char *p, *line;
|
||||||
|
+ size_t size;
|
||||||
|
|
||||||
|
- fclose(fp);
|
||||||
|
+ line = slurp_proc_file("/proc/cmdline", &size);
|
||||||
|
+ if (!line || !size)
|
||||||
|
+ die("Failed to read /proc/cmdline\n");
|
||||||
|
|
||||||
|
/* strip newline */
|
||||||
|
- line[strlen(line) - 1] = '\0';
|
||||||
|
+ line[size-1] = '\0';
|
||||||
|
+
|
||||||
|
+ p = strpbrk(line, "\r\n");
|
||||||
|
+ if (p)
|
||||||
|
+ *p = '\0';
|
||||||
|
|
||||||
|
remove_parameter(line, "BOOT_IMAGE");
|
||||||
|
if (kexec_flags & KEXEC_ON_CRASH)
|
@ -107,6 +107,7 @@ Requires: systemd-udev%{?_isa}
|
|||||||
Patch401: ./kexec-tools-2.0.23-01-s390_add_variable_command_line_size.patch
|
Patch401: ./kexec-tools-2.0.23-01-s390_add_variable_command_line_size.patch
|
||||||
Patch402: ./kexec-tools-2.0.23-02-s390_use_KEXEC_ALL_OPTIONS.patch
|
Patch402: ./kexec-tools-2.0.23-02-s390_use_KEXEC_ALL_OPTIONS.patch
|
||||||
Patch403: ./kexec-tools-2.0.23-03-add_slurp_proc_file_.patch
|
Patch403: ./kexec-tools-2.0.23-03-add_slurp_proc_file_.patch
|
||||||
|
Patch404: ./kexec-tools-2.0.23-04-use_slurp_proc_file_in_get_command_line_.patch
|
||||||
|
|
||||||
#
|
#
|
||||||
# Patches 501 through 600 are meant for ARM kexec-tools enablement
|
# Patches 501 through 600 are meant for ARM kexec-tools enablement
|
||||||
@ -140,6 +141,7 @@ tar -z -x -v -f %{SOURCE19}
|
|||||||
%patch401 -p1
|
%patch401 -p1
|
||||||
%patch402 -p1
|
%patch402 -p1
|
||||||
%patch403 -p1
|
%patch403 -p1
|
||||||
|
%patch404 -p1
|
||||||
%patch601 -p1
|
%patch601 -p1
|
||||||
%patch602 -p1
|
%patch602 -p1
|
||||||
%patch603 -p1
|
%patch603 -p1
|
||||||
|
Loading…
Reference in New Issue
Block a user