Fix errors on compressed NTFS with 512B clusters.

* include/grub/ntfs.h (grub_ntfscomp_func_t): Use appropriately sized
	types.
	* grub-core/fs/ntfs.c (grub_ntfs_read): Return correct -1 on error and
	not 0.
	* grub-core/fs/ntfscomp.c (read_block): Use appropriately-sized types.
	Relax check for inline extents.
	(ntfscomp): Return correct -1 on error and not 0.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-05-04 17:37:17 +02:00
parent 4f8e368fc0
commit 1b8463f2c4
4 changed files with 23 additions and 10 deletions

View file

@ -1,3 +1,15 @@
2012-05-04 Vladimir Serbinenko <phcoder@gmail.com>
Fix errors on compressed NTFS with 512B clusters.
* include/grub/ntfs.h (grub_ntfscomp_func_t): Use appropriately sized
types.
* grub-core/fs/ntfs.c (grub_ntfs_read): Return correct -1 on error and
not 0.
* grub-core/fs/ntfscomp.c (read_block): Use appropriately-sized types.
Relax check for inline extents.
(ntfscomp): Return correct -1 on error and not 0.
2012-05-04 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-install.in: Fix handling of prefix containing spaces.

View file

@ -1121,7 +1121,7 @@ grub_ntfs_read (grub_file_t file, char *buf, grub_size_t len)
mft->attr.save_pos = 1;
read_attr (&mft->attr, buf, file->offset, len, 1, file->read_hook);
return (grub_errno) ? 0 : len;
return (grub_errno) ? -1 : (grub_ssize_t) len;
}
static grub_err_t

View file

@ -176,18 +176,19 @@ decomp_block (struct grub_ntfs_comp *cc, char *dest)
}
static grub_err_t
read_block (struct grub_ntfs_rlst *ctx, char *buf, int num)
read_block (struct grub_ntfs_rlst *ctx, char *buf, grub_size_t num)
{
int cpb = GRUB_NTFS_COM_SEC / ctx->comp.spc;
while (num)
{
int nn;
grub_size_t nn;
if ((ctx->target_vcn & 0xF) == 0)
{
if (ctx->comp.comp_head != ctx->comp.comp_tail)
if (ctx->comp.comp_head != ctx->comp.comp_tail
&& !(ctx->flags & GRUB_NTFS_RF_BLNK))
return grub_error (GRUB_ERR_BAD_FS, "invalid compression block");
ctx->comp.comp_head = ctx->comp.comp_tail = 0;
ctx->comp.cbuf_vcn = ctx->target_vcn;
@ -243,7 +244,7 @@ read_block (struct grub_ntfs_rlst *ctx, char *buf, int num)
nn *= cpb;
while ((ctx->comp.comp_head < ctx->comp.comp_tail) && (nn))
{
int tt;
grub_disk_addr_t tt;
tt =
ctx->comp.comp_table[ctx->comp.comp_head][0] -
@ -287,8 +288,8 @@ read_block (struct grub_ntfs_rlst *ctx, char *buf, int num)
}
static grub_err_t
ntfscomp (struct grub_ntfs_attr *at, char *dest, grub_uint32_t ofs,
grub_uint32_t len, struct grub_ntfs_rlst *ctx, grub_uint32_t vcn)
ntfscomp (struct grub_ntfs_attr *at, char *dest, grub_disk_addr_t ofs,
grub_size_t len, struct grub_ntfs_rlst *ctx, grub_disk_addr_t vcn)
{
grub_err_t ret;

View file

@ -181,10 +181,10 @@ struct grub_ntfs_rlst
typedef grub_err_t (*grub_ntfscomp_func_t) (struct grub_ntfs_attr * at,
char *dest,
grub_uint32_t ofs,
grub_uint32_t len,
grub_disk_addr_t ofs,
grub_size_t len,
struct grub_ntfs_rlst * ctx,
grub_uint32_t vcn);
grub_disk_addr_t vcn);
extern grub_ntfscomp_func_t grub_ntfscomp_func;