]> Dogcows Code - chaz/tar/commitdiff
(xheader_decode): Store the header as well (for eventual delete).
authorSergey Poznyakoff <gray@gnu.org.ua>
Thu, 4 Sep 2003 13:59:52 +0000 (13:59 +0000)
committerSergey Poznyakoff <gray@gnu.org.ua>
Thu, 4 Sep 2003 13:59:52 +0000 (13:59 +0000)
src/xheader.c

index 3926a7f81ad2601437cec8afe6dbc9a1e1653786..1f1b190d0cc5eca9b47fb3c57b8c9f138e619b81 100644 (file)
@@ -107,7 +107,7 @@ decode_record (char **p, struct tar_stat_info *st)
 void
 xheader_decode (struct tar_stat_info *st)
 {
-  char *p = extended_header.buffer;
+  char *p = extended_header.buffer + BLOCKSIZE;
   char *endp = &extended_header.buffer[extended_header.size-1];
 
   while (p < endp)
@@ -136,29 +136,31 @@ xheader_store (char const *keyword, struct tar_stat_info const *st)
 void
 xheader_read (union block *p, size_t size)
 {
-  size_t i, j;
+  size_t j = 0;
   size_t nblocks;
 
   free (extended_header.buffer);
+  size += BLOCKSIZE;
   extended_header.size = size;
   nblocks = (size + BLOCKSIZE - 1) / BLOCKSIZE;
   extended_header.buffer = xmalloc (size + 1);
 
-  set_next_block_after (p);
-  for (i = j = 0; i < nblocks; i++)
+  do
     {
-      size_t len;
+      size_t len = size;
 
-      p = find_next_block ();
-      len = size;
       if (len > BLOCKSIZE)
        len = BLOCKSIZE;
+      
       memcpy (&extended_header.buffer[j], p->buffer, len);
       set_next_block_after (p);
 
+      p = find_next_block ();
+
       j += len;
       size -= len;
     }
+  while (size > 0);
 }
 
 static size_t
This page took 0.024712 seconds and 4 git commands to generate.