On Mon, 2013-01-28 at 14:59 +0100, Pavel Raiskup wrote:
> On Mon, 2013-01-28 at 10:17 +0100, Pavel Raiskup wrote:
> > Hi Paul,
> > 
> > > Thanks for catching that bug.  We don't yet have a facility
> > > for large test cases, so I guess we can put that on the todo list.
> > 
> > I agree (this is probably about paxutils?).
> > 
> > > Your patch doesn't feel quite right, as there's a similar
> > > issue in pax_dump_header_0, and also there's a problem if
> > > the shrunken size is less than 8 GiB but the real size is not.
> > > I pushed the following patch instead: does it fix things for you?
> > 
> > Of course, it fixes the issue.  Thanks for this!
> 
> Another small problem: tar is unable to list such archive (containing
> sparse file(s) of size >8GB).  It does not honor the size=N extended
> header during reading.  This is because the file_stat->archive_file_size
> is set based on basic header field only before xheader_decode() is
> executed.
> 
> Could you consider/use as inspiration the following fix?  Thanks.

Re-sending patch with added comments (attached).

Pavel



diff --git a/src/xheader.c b/src/xheader.c
index c8c54b6..ff5c9c3 100644
--- a/src/xheader.c
+++ b/src/xheader.c
@@ -1305,7 +1305,17 @@ size_decoder (struct tar_stat_info *st,
 {
   uintmax_t u;
   if (decode_num (&u, arg, TYPE_MAXIMUM (off_t), keyword))
-    st->stat.st_size = u;
+    {
+      if (u > st->stat.st_size)
+	/* Do *not* overwrite stat.st_size when it has been set by
+	   GNU.sparse.realsize (func sparse_size_decoder) already. */
+	st->stat.st_size = u;
+
+      /* Inherit the effective size from extended header.  This is needed
+	 especially for sparse files - they coul'd have zero value otherwise
+	 inherited from default (non-extended) header field */
+      st->archive_file_size = u;
+    }
 }
 
 static void

Reply via email to