+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
(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;
}
}