summaryrefslogtreecommitdiff
path: root/ext/zip/lib/zip_source_buffer.c
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2012-07-23 10:51:19 +0200
committerOndřej Surý <ondrej@sury.org>2012-07-23 10:51:19 +0200
commit3365f28adf90110ca7475df889720fc244820f4b (patch)
tree5415edde3e396a93f05f887d9f07071871467bdf /ext/zip/lib/zip_source_buffer.c
parentf0f8d7084aec4be5c07f02f2e29c2820f85c8315 (diff)
downloadphp-3365f28adf90110ca7475df889720fc244820f4b.tar.gz
Imported Upstream version 5.4.5upstream/5.4.5
Diffstat (limited to 'ext/zip/lib/zip_source_buffer.c')
-rw-r--r--ext/zip/lib/zip_source_buffer.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/ext/zip/lib/zip_source_buffer.c b/ext/zip/lib/zip_source_buffer.c
index 867d3dfa3..8c9154ce3 100644
--- a/ext/zip/lib/zip_source_buffer.c
+++ b/ext/zip/lib/zip_source_buffer.c
@@ -1,6 +1,6 @@
/*
zip_source_buffer.c -- create zip data source from buffer
- Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <libzip@nih.at>
@@ -44,13 +44,12 @@ struct read_data {
int freep;
};
-static ssize_t read_data(void *state, void *data, size_t len,
- enum zip_source_cmd cmd);
+static zip_int64_t read_data(void *, void *, zip_uint64_t, enum zip_source_cmd);
ZIP_EXTERN(struct zip_source *)
-zip_source_buffer(struct zip *za, const void *data, off_t len, int freep)
+zip_source_buffer(struct zip *za, const void *data, zip_uint64_t len, int freep)
{
struct read_data *f;
struct zip_source *zs;
@@ -58,7 +57,7 @@ zip_source_buffer(struct zip *za, const void *data, off_t len, int freep)
if (za == NULL)
return NULL;
- if (len < 0 || (data == NULL && len > 0)) {
+ if (data == NULL && len > 0) {
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
return NULL;
}
@@ -83,12 +82,12 @@ zip_source_buffer(struct zip *za, const void *data, off_t len, int freep)
-static ssize_t
-read_data(void *state, void *data, size_t len, enum zip_source_cmd cmd)
+static zip_int64_t
+read_data(void *state, void *data, zip_uint64_t len, enum zip_source_cmd cmd)
{
struct read_data *z;
char *buf;
- size_t n;
+ zip_uint64_t n;
z = (struct read_data *)state;
buf = (char *)data;
@@ -99,6 +98,8 @@ read_data(void *state, void *data, size_t len, enum zip_source_cmd cmd)
return 0;
case ZIP_SOURCE_READ:
+ /* XXX: return error if (len > ZIP_INT64_MAX) */
+
n = z->end - z->buf;
if (n > len)
n = len;
@@ -125,6 +126,11 @@ read_data(void *state, void *data, size_t len, enum zip_source_cmd cmd)
zip_stat_init(st);
st->mtime = z->mtime;
st->size = z->end - z->data;
+ st->comp_size = st->size;
+ st->comp_method = ZIP_CM_STORE;
+ st->encryption_method = ZIP_EM_NONE;
+ st->valid = ZIP_STAT_MTIME|ZIP_STAT_SIZE|ZIP_STAT_COMP_SIZE
+ |ZIP_STAT_COMP_METHOD|ZIP_STAT_ENCRYPTION_METHOD;
return sizeof(*st);
}