]> git.proxmox.com Git - grub2.git/commitdiff
grub_fshelp_read_file: Don't attempt to read past the end of file.
authorVladimir Serbinenko <phcoder@gmail.com>
Tue, 20 Jan 2015 11:58:17 +0000 (12:58 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Wed, 21 Jan 2015 16:38:04 +0000 (17:38 +0100)
ChangeLog
grub-core/fs/fshelp.c

index 80ef35c626291da4cc0a83c7bcba118411582041..c18ab2da6deaee5b18dda6b8f3bc775eca41866d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-20  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/fs/fshelp.c (grub_fshelp_read_file): Don't attempt to read
+       past the end of file.
+
 2015-01-20  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/script/lexer.c (grub_script_lexer_yywrap): Update len
index 42bd542bbc3525cedf3ccdc090e2e351b8375572..b899bed0401f72794b0021cf0863dfc5764bd7b7 100644 (file)
@@ -252,6 +252,13 @@ grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
   grub_disk_addr_t i, blockcnt;
   int blocksize = 1 << (log2blocksize + GRUB_DISK_SECTOR_BITS);
 
+  if (pos > filesize)
+    {
+      grub_error (GRUB_ERR_OUT_OF_RANGE,
+                 N_("attempt to read past the end of file"));
+      return -1;
+    }
+
   /* Adjust LEN so it we can't read past the end of the file.  */
   if (pos + len > filesize)
     len = filesize - pos;