summaryrefslogtreecommitdiff
path: root/ext/zip/lib/zip_file_get_offset.c
diff options
context:
space:
mode:
authorRemi Collet <remi@php.net>2013-11-04 13:23:36 +0100
committerRemi Collet <remi@php.net>2013-11-04 13:23:36 +0100
commit5dc37b351085a7b8cdc30ef2ebb349c8e5df4e2c (patch)
tree33357220b91d8553c0978e6392385e0fb8e49028 /ext/zip/lib/zip_file_get_offset.c
parent2f555b8e606b5f09d635cef4d3fcbcd6939adae2 (diff)
downloadphp-git-5dc37b351085a7b8cdc30ef2ebb349c8e5df4e2c.tar.gz
Sync ext/zip with pecl/zip version 1.3.2
- update libzip to version 1.11.1. We don't use any private symbol anymore - new method ZipArchive::setPassword($password) - add --with-libzip option to build with system libzip
Diffstat (limited to 'ext/zip/lib/zip_file_get_offset.c')
-rw-r--r--ext/zip/lib/zip_file_get_offset.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/ext/zip/lib/zip_file_get_offset.c b/ext/zip/lib/zip_file_get_offset.c
index b96fd5e480..65a011fc07 100644
--- a/ext/zip/lib/zip_file_get_offset.c
+++ b/ext/zip/lib/zip_file_get_offset.c
@@ -50,25 +50,27 @@
On error, fills in za->error and returns 0.
*/
-unsigned int
-_zip_file_get_offset(struct zip *za, int idx)
+zip_uint64_t
+_zip_file_get_offset(const struct zip *za, zip_uint64_t idx, struct zip_error *error)
{
- struct zip_dirent de;
- unsigned int offset;
+ zip_uint64_t offset;
+ zip_int32_t size;
- offset = za->cdir->entry[idx].offset;
+ offset = za->entry[idx].orig->offset;
- if (fseeko(za->zp, offset, SEEK_SET) != 0) {
- _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
+ if (fseeko(za->zp, (off_t)offset, SEEK_SET) != 0) {
+ _zip_error_set(error, ZIP_ER_SEEK, errno);
return 0;
}
- if (_zip_dirent_read(&de, za->zp, NULL, NULL, 1, &za->error) != 0)
+ /* XXX: cache? */
+ if ((size=_zip_dirent_size(za->zp, ZIP_EF_LOCAL, error)) < 0)
return 0;
- offset += LENTRYSIZE + de.filename_len + de.extrafield_len;
-
- _zip_dirent_finalize(&de);
-
- return offset;
+ if (offset+(zip_uint32_t)size > ZIP_OFF_MAX) {
+ _zip_error_set(error, ZIP_ER_SEEK, EFBIG);
+ return 0;
+ }
+
+ return offset + (zip_uint32_t)size;
}