From ba5054cc77bef76dae44b3debc80a499d36b782d Mon Sep 17 00:00:00 2001 From: Ray Strode <rstrode@redhat.com> Date: Fri, 19 Nov 2010 15:27:12 -0500 Subject: [PATCH 1/3] terminal: don't rely on strlen(bytes) for write size We're printing stuff to the terminal. This may include NUL bytes once in a while. We shouldn't rely on strlen() to determine how many bytes to write. --- src/libply-splash-core/ply-terminal.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libply-splash-core/ply-terminal.c b/src/libply-splash-core/ply-terminal.c index 22db27d..a4b2a5a 100644 --- a/src/libply-splash-core/ply-terminal.c +++ b/src/libply-splash-core/ply-terminal.c @@ -271,16 +271,17 @@ ply_terminal_write (ply_terminal_t *terminal, { va_list args; char *string; + int size; assert (terminal != NULL); assert (format != NULL); string = NULL; va_start (args, format); - vasprintf (&string, format, args); + size = vasprintf (&string, format, args); va_end (args); - write (terminal->fd, string, strlen (string)); + write (terminal->fd, string, size); free (string); } -- 1.7.3.2 From cd0b8662227e09f9032d4d40f74307853809d7b5 Mon Sep 17 00:00:00 2001 From: Ray Strode <rstrode@redhat.com> Date: Fri, 19 Nov 2010 19:33:34 -0500 Subject: [PATCH 2/3] main: Always translate tty0 to tty1 Another bug in check_for_consoles... We can't ever write to tty0 directly, because it is redirected (just like /dev/console). Previously we would translate the call to tty1, but commit c40fd792b6edf931a6bbe2ec23518b57483a4e2f broke that. This commit fixes it again. --- src/main.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main.c b/src/main.c index b6ee878..1f55ff9 100644 --- a/src/main.c +++ b/src/main.c @@ -1784,6 +1784,12 @@ check_for_consoles (state_t *state, if (end != NULL) *end = '\0'; + if (strcmp (console, "tty0") == 0 || strcmp (console, "/dev/tty0") == 0) + { + free (console); + console = strdup (default_tty); + } + ply_trace ("serial console %s found!", console); ply_hashtable_insert (consoles, console, NULL); @@ -1794,12 +1800,7 @@ check_for_consoles (state_t *state, state->kernel_console_tty = NULL; if (console != NULL) - { - if (strcmp (console, "tty0") == 0 || strcmp (console, "/dev/tty0") == 0) - state->kernel_console_tty = strdup (default_tty); - else - state->kernel_console_tty = strdup (console); - } + state->kernel_console_tty = strdup (console); if (should_add_displays) { -- 1.7.3.2 From e5a78dd8bbd0a71ae159dcf79e88112e49d0f03f Mon Sep 17 00:00:00 2001 From: Ray Strode <rstrode@redhat.com> Date: Fri, 19 Nov 2010 19:35:52 -0500 Subject: [PATCH 3/3] main: remove tty0 from list of fallback ttys It's not a valid fallback tty since writing to it would create a feedback loop (since it's redirected with /dev/console) --- src/main.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/src/main.c b/src/main.c index 1f55ff9..d5b1632 100644 --- a/src/main.c +++ b/src/main.c @@ -1856,7 +1856,6 @@ find_fallback_tty (state_t *state) "/dev/hvc0", "/dev/xvc0", "/dev/ttySG0", - "/dev/tty0", NULL }; int i; -- 1.7.3.2