]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Out-of-range seeks should fail, not truncate the seek.
authorTim Kientzle <kientzle@acm.org>
Thu, 26 Dec 2013 21:59:00 +0000 (13:59 -0800)
committerTim Kientzle <kientzle@acm.org>
Thu, 26 Dec 2013 21:59:00 +0000 (13:59 -0800)
libarchive/archive_read.c

index cc05588b60f8d1c8d856fe294bf8d84d1505ef2b..c9f28b869fc39937536b676c93c990981e56cc76 100644 (file)
@@ -1614,10 +1614,9 @@ __archive_read_filter_seek(struct archive_read_filter *filter, int64_t offset,
                        client->dataset[++cursor].begin_position = r;
                }
                offset -= client->dataset[cursor].begin_position;
-               if (offset < 0)
-                       offset = 0;
-               else if (offset > client->dataset[cursor].total_size - 1)
-                       offset = client->dataset[cursor].total_size - 1;
+               if (offset < 0
+                   || offset > client->dataset[cursor].total_size)
+                       return ARCHIVE_FATAL;
                if ((r = client_seek_proxy(filter, offset, SEEK_SET)) < 0)
                        return r;
                break;