1 |
From 9b46957ec98d85a572e9ef98301247f39338a3b5 Mon Sep 17 00:00:00 2001 |
2 |
From: Thomas Klausner <tk@giga.or.at> |
3 |
Date: Tue, 29 Aug 2017 10:25:03 +0200 |
4 |
Subject: [PATCH] Make eocd checks more consistent between zip and zip64 cases. |
5 |
|
6 |
--- |
7 |
lib/zip_open.c | 7 ++++++- |
8 |
1 file changed, 6 insertions(+), 1 deletion(-) |
9 |
|
10 |
diff --git a/lib/zip_open.c b/lib/zip_open.c |
11 |
index 3bd593b..9d3a4cb 100644 |
12 |
--- a/lib/zip_open.c |
13 |
+++ b/lib/zip_open.c |
14 |
@@ -847,7 +847,12 @@ _zip_read_eocd64(zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offse |
15 |
zip_error_set(error, ZIP_ER_SEEK, EFBIG); |
16 |
return NULL; |
17 |
} |
18 |
- if ((flags & ZIP_CHECKCONS) && offset+size != eocd_offset) { |
19 |
+ if (offset+size > buf_offset + eocd_offset) { |
20 |
+ /* cdir spans past EOCD record */ |
21 |
+ zip_error_set(error, ZIP_ER_INCONS, 0); |
22 |
+ return NULL; |
23 |
+ } |
24 |
+ if ((flags & ZIP_CHECKCONS) && offset+size != buf_offset + eocd_offset) { |
25 |
zip_error_set(error, ZIP_ER_INCONS, 0); |
26 |
return NULL; |
27 |
} |