]> git.proxmox.com Git - grub2.git/commitdiff
2008-09-22 Bean <bean123ch@gmail.com>
authorbean <bean@localhost>
Mon, 22 Sep 2008 04:18:57 +0000 (04:18 +0000)
committerbean <bean@localhost>
Mon, 22 Sep 2008 04:18:57 +0000 (04:18 +0000)
* fs/ntfs.c (grub_ntfs_iterate_dir): Fix a rare case where $BITMAP is
resident and in attribute list.

* include/grub/ntfs.h (BMP_LEN): Removed.

ChangeLog
fs/ntfs.c
include/grub/ntfs.h

index b4a0f767491ab74fe74920b8c195798b2b0be32e..ed44de64c432ec641f433f0adfee4bc45eb0be04 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-09-22  Bean  <bean123ch@gmail.com>
+
+       * fs/ntfs.c (grub_ntfs_iterate_dir): Fix a rare case where $BITMAP is
+       resident and in attribute list.
+
+       * include/grub/ntfs.h (BMP_LEN): Removed.
+
 2008-09-22  Bean  <bean123ch@gmail.com>
 
        * disk/ata.c (grub_apapi_open): Initialize devfnd, no need to set
index a590ade1ee0089ab5c101d5778356d64218e4512..e0e50f1649b28f390942faa5d584b8c1ed254a33 100644 (file)
--- a/fs/ntfs.c
+++ b/fs/ntfs.c
@@ -697,35 +697,32 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir,
          (u32at (cur_pos, ofs) == 0x490024) &&
          (u32at (cur_pos, ofs + 4) == 0x300033))
        {
-         if ((at->flags & AF_ALST) && (cur_pos[8] == 0))
-           {
-             grub_error (GRUB_ERR_BAD_FS,
-                         "$BITMAP should be non-resident when in attribute list");
-             goto done;
-           }
-         if (cur_pos[8] == 0)
-           {
-             bitmap = (unsigned char *) (cur_pos + u16at (cur_pos, 0x14));
-             bitmap_len = u32at (cur_pos, 0x10);
-             break;
-           }
-         if (u32at (cur_pos, 0x28) > BMP_LEN)
-           {
-             grub_error (GRUB_ERR_BAD_FS, "Non-resident $BITMAP too large");
-             goto done;
-           }
-         bmp = grub_malloc (u32at (cur_pos, 0x28));
-         if (bmp == NULL)
-           goto done;
+          int is_resident = (cur_pos[8] == 0);
+
+          bitmap_len = ((is_resident) ? u32at (cur_pos, 0x10) :
+                        (cur_pos, 0x28));
 
-         bitmap = (unsigned char *) bmp;
-         bitmap_len = u32at (cur_pos, 0x30);
-         if (read_data (at, cur_pos, bmp, 0, u32at (cur_pos, 0x28), 0, 0))
+          bmp = grub_malloc (bitmap_len);
+          if (bmp == NULL)
+            goto done;
+
+         if (is_resident)
            {
-             grub_error (GRUB_ERR_BAD_FS,
-                         "Fails to read non-resident $BITMAP");
-             goto done;
+              grub_memcpy (bmp, (char *) (cur_pos + u16at (cur_pos, 0x14)),
+                           bitmap_len);
            }
+          else
+            {
+              if (read_data (at, cur_pos, bmp, 0, bitmap_len, 0, 0))
+                {
+                  grub_error (GRUB_ERR_BAD_FS,
+                              "Fails to read non-resident $BITMAP");
+                  goto done;
+                }
+              bitmap_len = u32at (cur_pos, 0x30);
+            }
+
+          bitmap = (unsigned char *) bmp;
          break;
        }
     }
index bdd1a9ece82047d776dc1b5c48c753eb14d51f56..9b2ae0a0cdaaea2eabee394500250cab8ccbeec8 100644 (file)
@@ -75,8 +75,6 @@
 #define COM_LEN                4096
 #define COM_SEC                (COM_LEN >> BLK_SHR)
 
-#define BMP_LEN                4096
-
 #define AF_ALST                1
 #define AF_MMFT                2
 #define AF_GPOS                4