From: Ray Strode Date: Fri, 14 Nov 2008 18:25:56 +0000 (-0500) Subject: Don't loop forever when tty returns NUL bytes X-Git-Tag: 0.6.0~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1c18c7209776ceb7090758dbf139676aba1a0d89;p=thirdparty%2Fplymouth.git Don't loop forever when tty returns NUL bytes Somehow a user was running into a case where plymouthd would busy loop taking 100% cpu. gdb revealed that it was stuck trying to process keyboard input. This is apparently because we were looping forever when mbrlen() got a NUL byte. --- diff --git a/src/libplybootsplash/ply-window.c b/src/libplybootsplash/ply-window.c index e0222cde..d3c9e790 100644 --- a/src/libplybootsplash/ply-window.c +++ b/src/libplybootsplash/ply-window.c @@ -354,6 +354,14 @@ check_buffer_for_key_events (ply_window_t *window) if (character_size < 0) break; + /* If we're at a NUL character walk through it + */ + if (character_size == 0) + { + i++; + continue; + } + keyboard_input = strndup (bytes + i, character_size); process_keyboard_input (window, keyboard_input, character_size);