Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/vndcompress Seek if necessary at end of offtab_reset...



details:   https://anonhg.NetBSD.org/src/rev/2d8b8fe14d9e
branches:  trunk
changeset: 326202:2d8b8fe14d9e
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Jan 22 06:16:05 2014 +0000

description:
Seek if necessary at end of offtab_reset_read.

Fixes vnduncompress with a small window, and makes offtab_reset_read
symmetric with offtab_reset_write.

diffstat:

 usr.bin/vndcompress/offtab.c |  15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diffs (29 lines):

diff -r 57d90810c44a -r 2d8b8fe14d9e usr.bin/vndcompress/offtab.c
--- a/usr.bin/vndcompress/offtab.c      Wed Jan 22 06:15:57 2014 +0000
+++ b/usr.bin/vndcompress/offtab.c      Wed Jan 22 06:16:05 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: offtab.c,v 1.3 2014/01/22 06:15:31 riastradh Exp $     */
+/*     $NetBSD: offtab.c,v 1.4 2014/01/22 06:16:05 riastradh Exp $     */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -279,6 +279,19 @@
        if (!offtab_read_window(offtab, 0, OFFTAB_READ_NOSEEK))
                return false;
 
+       if (offtab->ot_window_size < offtab->ot_n_offsets) {
+               __CTASSERT(MAX_N_OFFSETS <= (OFF_MAX / sizeof(uint64_t)));
+               assert(offtab->ot_fdpos <= (OFF_MAX -
+                       (off_t)(offtab->ot_n_offsets * sizeof(uint64_t))));
+               const off_t first_offset = (offtab->ot_fdpos +
+                   (offtab->ot_n_offsets * sizeof(uint64_t)));
+               if (lseek(offtab->ot_fd, first_offset, SEEK_SET) == -1) {
+                       (*offtab->ot_report)("lseek to first offset 0x%"PRIx64,
+                           first_offset);
+                       return false;
+               }
+       }
+
        return true;
 }
 



Home | Main Index | Thread Index | Old Index