diff --git a/ChangeLog b/ChangeLog index 46c0ee188..54880f44f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-06-29 Colin Watson + + * commands/cat.c (grub_cmd_cat): Fix buffer overrun if '\r' is the + last character in the buffer. + Reported by: Vladimir Serbinenko. + 2010-06-29 Robert Millan * docs/grub.texi (Simple configuration): Document ${GRUB_BADRAM}. diff --git a/commands/cat.c b/commands/cat.c index 4c0e19bc2..289cf7352 100644 --- a/commands/cat.c +++ b/commands/cat.c @@ -63,7 +63,7 @@ grub_cmd_cat (grub_extcmd_t cmd, int argc, char **args) if ((grub_isprint (c) || grub_isspace (c)) && c != '\r') grub_putchar (c); - else if (dos && c == '\r' && buf[i + 1] == '\n') + else if (dos && c == '\r' && i + 1 < size && buf[i + 1] == '\n') { grub_putchar ('\n'); i++;