[1870] 2008-09-22 Bean <[email protected]>

Bean <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 1870
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=1870
Author:   bean
Date:     2008-09-22 04:18:57 +0000 (Mon, 22 Sep 2008)

Log Message:
-----------
2008-09-22  Bean  <[email protected]>

	* 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.

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/fs/ntfs.c
    trunk/grub2/include/grub/ntfs.h

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2008-09-22 03:49:26 UTC (rev 1869)
+++ trunk/grub2/ChangeLog	2008-09-22 04:18:57 UTC (rev 1870)
@@ -1,5 +1,12 @@
 2008-09-22  Bean  <[email protected]>
 
+	* 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  <[email protected]>
+
 	* disk/ata.c (grub_apapi_open): Initialize devfnd, no need to set
 	scsi->name and scsi->luns, as they will be set in grub_scsi_open.
 

Modified: trunk/grub2/fs/ntfs.c
===================================================================
--- trunk/grub2/fs/ntfs.c	2008-09-22 03:49:26 UTC (rev 1869)
+++ trunk/grub2/fs/ntfs.c	2008-09-22 04:18:57 UTC (rev 1870)
@@ -697,35 +697,32 @@
 	  (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 = (unsigned char *) bmp;
-	  bitmap_len = u32at (cur_pos, 0x30);
-	  if (read_data (at, cur_pos, bmp, 0, u32at (cur_pos, 0x28), 0, 0))
+          bitmap_len = ((is_resident) ? u32at (cur_pos, 0x10) :
+                        (cur_pos, 0x28));
+
+          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;
 	}
     }

Modified: trunk/grub2/include/grub/ntfs.h
===================================================================
--- trunk/grub2/include/grub/ntfs.h	2008-09-22 03:49:26 UTC (rev 1869)
+++ trunk/grub2/include/grub/ntfs.h	2008-09-22 04:18:57 UTC (rev 1870)
@@ -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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.