]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/kern/file.c (grub_file_read): Read nothing if len = 0.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 1 May 2012 13:08:29 +0000 (15:08 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 1 May 2012 13:08:29 +0000 (15:08 +0200)
Special behaviour for len = 0 to read whole file isn't used anywhere and
can cause buffer ovewrflows in several places.

ChangeLog
grub-core/kern/file.c

index 9c06c24ba94c8bdd6d2ca3bca62e3ea4f4484a4c..2934494916803d41a33000c73545ab24f0496f69 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-05-01  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/kern/file.c (grub_file_read): Read nothing if len = 0.
+       Special behaviour for len = 0 to read whole file isn't used anywhere and
+       can cause buffer ovewrflows in several places.
+
 2012-05-01  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/normal/autofs.c (read_fs_list): Fix memory leak.
index 4f1f59ff7a5130bc1f5c8c0dd680ac996d6edbc6..495326f1259b81240b4216a2db1aa5864f5c73ca 100644 (file)
@@ -143,7 +143,10 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len)
       return -1;
     }
 
-  if (len == 0 || len > file->size - file->offset)
+  if (len == 0)
+    return 0;
+
+  if (len > file->size - file->offset)
     len = file->size - file->offset;
 
   /* Prevent an overflow.  */