From: Sergey Poznyakoff Date: Tue, 2 Mar 2010 09:20:20 +0000 (+0200) Subject: Bugfix X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=3925776b41a69f592166ad03c92c4cbb01ee528a;p=chaz%2Ftar Bugfix * src/buffer.c (seek_archive): Rewrite size computation to prevent it from reaching negative values. Based on report by Denis Excoffier . --- diff --git a/src/buffer.c b/src/buffer.c index b47b773..6131038 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -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;