]> Dogcows Code - chaz/tar/commitdiff
Bugfix
authorSergey Poznyakoff <gray@gnu.org.ua>
Tue, 2 Mar 2010 09:20:20 +0000 (11:20 +0200)
committerSergey Poznyakoff <gray@gnu.org.ua>
Tue, 2 Mar 2010 09:20:20 +0000 (11:20 +0200)
* src/buffer.c (seek_archive): Rewrite size computation
to prevent it from reaching negative values. Based on
report by Denis Excoffier <Denis.Excoffier@free.fr>.

src/buffer.c

index b47b773ee8ea65c151db1fc8293e52ca8e58a433..61310381e88e1a8370431bd18e20cd79a7f56d5d 100644 (file)
@@ -854,16 +854,16 @@ seek_archive (off_t size)
   off_t start = current_block_ordinal ();
   off_t offset;
   off_t nrec, nblk;
-  off_t skipped = (blocking_factor - (current_block - record_start));
+  off_t skipped = (blocking_factor - (current_block - record_start))
+                  * BLOCKSIZE;
 
-  size -= skipped * BLOCKSIZE;
-
-  if (size < record_size)
+  if (size <= skipped)
     return 0;
-  /* FIXME: flush? */
-
+  
   /* Compute number of records to skip */
-  nrec = size / record_size;
+  nrec = (size - skipped) / record_size;
+  if (nrec == 0)
+    return 0;
   offset = rmtlseek (archive, nrec * record_size, SEEK_CUR);
   if (offset < 0)
     return offset;
This page took 0.026925 seconds and 4 git commands to generate.