]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/normal/menu_entry.c (insert_string): fix off by one
authorAndrey Borzenkov <arvidjaar@gmail.com>
Mon, 25 Feb 2013 21:42:25 +0000 (22:42 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 25 Feb 2013 21:42:25 +0000 (22:42 +0100)
access to unallocated memory.

ChangeLog
grub-core/normal/menu_entry.c

index 107c049cea5bd195ce0e5fe5345901aab4a2824e..cc5d5e35038a61a5c27e336b4918da1286cdfe5a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-02-25  Andrey Borzenkov <arvidjaar@gmail.com>
+
+       * grub-core/normal/menu_entry.c (insert_string): fix off by one
+       access to unallocated memory.
+
 2013-02-25  Andrey Borzenkov <arvidjaar@gmail.com>
 
        * Makefile.util.def: Add partmap/msdos.c to common library.
index 7cd67f360f73a3fef914819ca758ab4cbc1cebb1..85f97da136183b580ca85049178034256b632dfb 100644 (file)
@@ -393,11 +393,12 @@ insert_string (struct screen *screen, const char *s, int update)
          if (! screen->lines)
            return 0;
 
-         /* Scroll down. */
-         grub_memmove (screen->lines + screen->line + 2,
-                       screen->lines + screen->line + 1,
-                       ((screen->num_lines - screen->line - 2)
-                        * sizeof (struct line)));
+         /* Shift down if not appending after the last line. */
+         if (screen->line < screen->num_lines - 2)
+           grub_memmove (screen->lines + screen->line + 2,
+                         screen->lines + screen->line + 1,
+                         ((screen->num_lines - screen->line - 2)
+                          * sizeof (struct line)));
 
          if (! init_line (screen, screen->lines + screen->line + 1))
            return 0;