summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-03-02 11:20:20 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2010-03-02 11:20:20 +0200
commit3925776b41a69f592166ad03c92c4cbb01ee528a (patch)
treeade5630daa9e34cef9f030bb00f10d9b705975fc /src/buffer.c
parent762be4f2bd696b3fcc381da7d78fcdd4114215ec (diff)
downloadtar-3925776b41a69f592166ad03c92c4cbb01ee528a.tar.gz
Bugfix
* 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>.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/buffer.c b/src/buffer.c
index b47b773e..61310381 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;