From 3925776b41a69f592166ad03c92c4cbb01ee528a Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Tue, 2 Mar 2010 11:20:20 +0200 Subject: [PATCH] Bugfix * src/buffer.c (seek_archive): Rewrite size computation to prevent it from reaching negative values. Based on report by Denis Excoffier . --- src/buffer.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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; -- 2.45.2