commit-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[2544] 2009-08-28 Vladimir Serbinenko <address@hidden>


From: Vladimir Serbinenko
Subject: [2544] 2009-08-28 Vladimir Serbinenko <address@hidden>
Date: Fri, 28 Aug 2009 16:29:35 +0000

Revision: 2544
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2544
Author:   phcoder
Date:     2009-08-28 16:29:34 +0000 (Fri, 28 Aug 2009)
Log Message:
-----------
2009-08-28  Vladimir Serbinenko  <address@hidden>

        * kern/file.c (grub_file_read): Check offset.
        * fs/hfs.c (grub_hfs_read_file): Remove unnecessary offset check.
        * fs/jfs.c (grub_jfs_read_file): Likewise.
        * fs/ntfs.c (grub_ntfs_read): Likewise.
        * fs/reiserfs.c (grub_reiserfs_read): Likewise.
        * fs/minix.c (grub_minix_read_file): Correct offset check.
        * fs/ufs.c (grub_ufs_read_file): Likewise.

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/fs/hfs.c
    trunk/grub2/fs/jfs.c
    trunk/grub2/fs/minix.c
    trunk/grub2/fs/ntfs.c
    trunk/grub2/fs/reiserfs.c
    trunk/grub2/fs/ufs.c
    trunk/grub2/kern/file.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog       2009-08-28 14:10:02 UTC (rev 2543)
+++ trunk/grub2/ChangeLog       2009-08-28 16:29:34 UTC (rev 2544)
@@ -1,3 +1,13 @@
+2009-08-28  Vladimir Serbinenko  <address@hidden>
+
+       * kern/file.c (grub_file_read): Check offset.
+       * fs/hfs.c (grub_hfs_read_file): Remove unnecessary offset check.
+       * fs/jfs.c (grub_jfs_read_file): Likewise.
+       * fs/ntfs.c (grub_ntfs_read): Likewise.
+       * fs/reiserfs.c (grub_reiserfs_read): Likewise.
+       * fs/minix.c (grub_minix_read_file): Correct offset check.
+       * fs/ufs.c (grub_ufs_read_file): Likewise.
+
 2009-08-28  Colin Watson  <address@hidden>
 
        * term/i386/pc/console.c (bios_data_area): Cast

Modified: trunk/grub2/fs/hfs.c
===================================================================
--- trunk/grub2/fs/hfs.c        2009-08-28 14:10:02 UTC (rev 2543)
+++ trunk/grub2/fs/hfs.c        2009-08-28 16:29:34 UTC (rev 2544)
@@ -243,10 +243,6 @@
   int i;
   int blockcnt;
 
-  /* Adjust len so it we can't read past the end of the file.  */
-  if (len > grub_le_to_cpu32 (data->size))
-    len = grub_le_to_cpu32 (data->size);
-
   blockcnt = ((len + pos)
              + data->blksz - 1) / data->blksz;
 

Modified: trunk/grub2/fs/jfs.c
===================================================================
--- trunk/grub2/fs/jfs.c        2009-08-28 14:10:02 UTC (rev 2543)
+++ trunk/grub2/fs/jfs.c        2009-08-28 16:29:34 UTC (rev 2544)
@@ -544,10 +544,6 @@
   int i;
   int blockcnt;
 
-  /* Adjust len so it we can't read past the end of the file.  */
-  if (len > data->currinode.size)
-    len = data->currinode.size;
-
   blockcnt = ((len + pos + grub_le_to_cpu32 (data->sblock.blksz) - 1)
              / grub_le_to_cpu32 (data->sblock.blksz));
 

Modified: trunk/grub2/fs/minix.c
===================================================================
--- trunk/grub2/fs/minix.c      2009-08-28 14:10:02 UTC (rev 2543)
+++ trunk/grub2/fs/minix.c      2009-08-28 16:29:34 UTC (rev 2544)
@@ -193,8 +193,8 @@
   int blockcnt;
 
   /* Adjust len so it we can't read past the end of the file.  */
-  if (len > GRUB_MINIX_INODE_SIZE (data))
-    len = GRUB_MINIX_INODE_SIZE (data);
+  if (len + pos > GRUB_MINIX_INODE_SIZE (data))
+    len = GRUB_MINIX_INODE_SIZE (data) - pos;
 
   blockcnt = (len + pos + GRUB_MINIX_BSIZE - 1) / GRUB_MINIX_BSIZE;
 

Modified: trunk/grub2/fs/ntfs.c
===================================================================
--- trunk/grub2/fs/ntfs.c       2009-08-28 14:10:02 UTC (rev 2543)
+++ trunk/grub2/fs/ntfs.c       2009-08-28 16:29:34 UTC (rev 2544)
@@ -970,15 +970,6 @@
   if (file->read_hook)
     mft->attr.save_pos = 1;
 
-  if (file->offset > file->size)
-    {
-      grub_error (GRUB_ERR_BAD_FS, "Bad offset");
-      return -1;
-    }
-
-  if (file->offset + len > file->size)
-    len = file->size - file->offset;
-
   read_attr (&mft->attr, buf, file->offset, len, 1, file->read_hook);
   return (grub_errno) ? 0 : len;
 }

Modified: trunk/grub2/fs/reiserfs.c
===================================================================
--- trunk/grub2/fs/reiserfs.c   2009-08-28 14:10:02 UTC (rev 2543)
+++ trunk/grub2/fs/reiserfs.c   2009-08-28 16:29:34 UTC (rev 2544)
@@ -1077,9 +1077,6 @@
   grub_disk_addr_t block;
   grub_off_t offset;
 
-  if (file->offset >= file->size)
-    return 0;
-
   key.directory_id = node->header.key.directory_id;
   key.object_id = node->header.key.object_id;
   key.u.v2.offset_type = 0;

Modified: trunk/grub2/fs/ufs.c
===================================================================
--- trunk/grub2/fs/ufs.c        2009-08-28 14:10:02 UTC (rev 2543)
+++ trunk/grub2/fs/ufs.c        2009-08-28 16:29:34 UTC (rev 2544)
@@ -290,8 +290,8 @@
   int blockcnt;
 
   /* Adjust len so it we can't read past the end of the file.  */
-  if (len > INODE_SIZE (data))
-    len = INODE_SIZE (data);
+  if (len + pos > INODE_SIZE (data))
+    len = INODE_SIZE (data) - pos;
 
   blockcnt = (len + pos + UFS_BLKSZ (sblock) - 1) / UFS_BLKSZ (sblock);
 

Modified: trunk/grub2/kern/file.c
===================================================================
--- trunk/grub2/kern/file.c     2009-08-28 14:10:02 UTC (rev 2543)
+++ trunk/grub2/kern/file.c     2009-08-28 16:29:34 UTC (rev 2544)
@@ -112,6 +112,13 @@
 {
   grub_ssize_t res;
 
+  if (file->offset > file->size)
+    {
+      grub_error (GRUB_ERR_OUT_OF_RANGE,
+                 "Attempt to read pat the end of file.");
+      return -1;
+    }
+
   if (len == 0 || len > file->size - file->offset)
     len = file->size - file->offset;
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]