]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Don't loop forever when tty returns NUL bytes
authorRay Strode <rstrode@redhat.com>
Fri, 14 Nov 2008 18:25:56 +0000 (13:25 -0500)
committerRay Strode <rstrode@redhat.com>
Mon, 17 Nov 2008 14:55:18 +0000 (09:55 -0500)
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.

src/libplybootsplash/ply-window.c

index e0222cde53cc00968993a0e283d9829430a324a2..d3c9e790ec75369aeb6b144221f7ea568460441f 100644 (file)
@@ -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);