xenithorb / rpms / plymouth

Forked from rpms/plymouth 6 years ago
Clone
Blob Blame History Raw
From b7c7bdbf7639ebfd16875cba63f2a63404193ec4 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 10 Sep 2010 15:43:28 -0400
Subject: [PATCH] main: Fix up check_for_consoles

commit c40fd792b6edf931a6bbe2ec23518b57483a4e2f was just wrong.

Attempt to fix it up to be less awful.
---
 src/main.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/main.c b/src/main.c
index 27ec95c..b06dbdc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1755,8 +1755,9 @@ check_for_consoles (state_t    *state,
                     const char *default_tty,
                     bool        should_add_displays)
 {
-  const char *console;
+  const char *console_string;
   const char *remaining_command_line;
+  char *console;
   ply_hashtable_t *consoles;
 
   ply_trace ("checking for consoles%s",
@@ -1766,25 +1767,26 @@ check_for_consoles (state_t    *state,
 
   consoles = ply_hashtable_new (ply_hashtable_string_hash,
                                 ply_hashtable_string_compare);
-  while ((console = command_line_get_string_after_prefix (remaining_command_line,
-                                                          "console=")) != NULL)
+  while ((console_string = command_line_get_string_after_prefix (remaining_command_line,
+                                                                 "console=")) != NULL)
     {
       char *end;
 
-      state->should_force_details = true;
+      remaining_command_line = console_string;
 
-      ply_trace ("serial console %s found!", console);
-      ply_hashtable_insert (consoles, strdup (console), NULL);
+      state->should_force_details = true;
 
-      remaining_command_line = console;
+      console = strdup (console_string);
 
-      end = strpbrk (state->kernel_console_tty, " \n\t\v,");
+      end = strpbrk (console, " \n\t\v,");
 
       if (end != NULL)
-        {
-          *end = '\0';
-          console += end - state->kernel_console_tty;
-        }
+        *end = '\0';
+
+      ply_trace ("serial console %s found!", console);
+      ply_hashtable_insert (consoles, console, NULL);
+
+      remaining_command_line += strlen (console);
     }
 
   free (state->kernel_console_tty);
-- 
1.7.3.1

From 18541c1d58612f1535972c54940bbb460c5cab06 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Thu, 7 Oct 2010 12:47:47 -0400
Subject: [PATCH] main: NULL initialize "console" variable

check_for_consoles is a really small function, that has historically
been loaded with bugs.

This commit fixes another bug in it, where the consoles variable is
never initialized to NULL.
---
 src/main.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/main.c b/src/main.c
index 2787aed..7358c24 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1765,6 +1765,7 @@ check_for_consoles (state_t    *state,
 
   remaining_command_line = state->kernel_command_line;
 
+  console = NULL;
   consoles = ply_hashtable_new (ply_hashtable_string_hash,
                                 ply_hashtable_string_compare);
   while ((console_string = command_line_get_string_after_prefix (remaining_command_line,
-- 
1.7.3.1