]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Fix errors on compressed NTFS with 512B clusters.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 4 May 2012 15:37:17 +0000 (17:37 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 4 May 2012 15:37:17 +0000 (17:37 +0200)
* 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.

ChangeLog
grub-core/fs/ntfs.c
grub-core/fs/ntfscomp.c
include/grub/ntfs.h

index d46d7f100623a5eacb0755249274954bb8196d28..a76e378c7cbae9ef6f816c1ba452c614949c453f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index 30293ddfe95bb2f68eb7627086a4e8da341aecb1..eb831a149bf61521e4958388f39a153495adceaa 100644 (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
index 890faa3bf74d30b27aa2f64f8b5763b6c009c290..88e3ee58251d6189a83694c2a4fc3d0db959ae07 100644 (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;
 
index 5cdd5f73f4a7694c61ed1ee53de3308452d8ae81..0ecbce95d9d39a8a8bbf57c73e33c3420a4b9b3b 100644 (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;