]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
grub-mklayout: check subscript bounds
authorAndrei Borzenkov <arvidjaar@gmail.com>
Sat, 9 Jan 2016 11:13:36 +0000 (14:13 +0300)
committerAndrei Borzenkov <arvidjaar@gmail.com>
Sat, 9 Jan 2016 11:13:36 +0000 (14:13 +0300)
Found by: Coverity scan.
CID: 73686

util/grub-mklayout.c

index 1a4f1b4c8553f9e4e1c1eee80a1ff1805f7f5e83..d171c2700ff584f2a659e2e96ee6a515a903b8ca 100644 (file)
@@ -384,6 +384,13 @@ write_keymaps (FILE *in, FILE *out, const char *out_filename)
          sscanf (line, "keycode %u = %60s %60s %60s %60s", &keycode_linux,
                  normal, shift, normalalt, shiftalt);
 
+         if (keycode_linux >= ARRAY_SIZE (linux_to_usb_map))
+           {
+             /* TRANSLATORS: scan code is keyboard key numeric identifier.  */
+             fprintf (stderr, _("Unknown keyboard scan code 0x%02x\n"), keycode_linux);
+             continue;
+           }
+
          /* Not used.  */
          if (keycode_linux == 0x77 /* Pause */
              /* Some obscure keys */