summaryrefslogtreecommitdiff
path: root/ext/zip/lib
diff options
context:
space:
mode:
Diffstat (limited to 'ext/zip/lib')
-rw-r--r--ext/zip/lib/zip.h6
-rw-r--r--ext/zip/lib/zip_add_dir.c83
-rw-r--r--ext/zip/lib/zip_close.c10
-rw-r--r--ext/zip/lib/zip_dirent.c11
-rw-r--r--ext/zip/lib/zip_error.c13
-rw-r--r--ext/zip/lib/zip_error_clear.c47
-rw-r--r--ext/zip/lib/zip_error_strerror.c8
-rw-r--r--ext/zip/lib/zip_fclose.c14
-rw-r--r--ext/zip/lib/zip_file_error_clear.c47
-rw-r--r--ext/zip/lib/zip_free.c3
-rw-r--r--ext/zip/lib/zip_get_archive_comment.c2
-rw-r--r--ext/zip/lib/zip_open.c7
-rw-r--r--ext/zip/lib/zip_set_archive_comment.c2
-rw-r--r--ext/zip/lib/zip_source_buffer.c6
-rw-r--r--ext/zip/lib/zip_source_file.c4
-rw-r--r--ext/zip/lib/zip_source_filep.c12
-rw-r--r--ext/zip/lib/zip_stat_index.c4
-rw-r--r--ext/zip/lib/zip_stat_init.c53
-rw-r--r--ext/zip/lib/zipint.h1
19 files changed, 293 insertions, 40 deletions
diff --git a/ext/zip/lib/zip.h b/ext/zip/lib/zip.h
index 8cf690cad..de115d38a 100644
--- a/ext/zip/lib/zip.h
+++ b/ext/zip/lib/zip.h
@@ -5,7 +5,7 @@
$NiH: zip.h,v 1.57 2006/04/24 14:04:19 dillo Exp $
zip.h -- exported declarations.
- Copyright (C) 1999-2006 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <nih@giga.or.at>
@@ -163,12 +163,15 @@ struct zip_source;
int zip_add(struct zip *, const char *, struct zip_source *);
+int zip_add_dir(struct zip *, const char *);
int zip_close(struct zip *);
int zip_delete(struct zip *, int);
+void zip_error_clear(struct zip *);
void zip_error_get(struct zip *, int *, int *);
int zip_error_get_sys_type(int);
int zip_error_to_str(char *, size_t, int, int);
int zip_fclose(struct zip_file *);
+void zip_file_error_clear(struct zip_file *);
void zip_file_error_get(struct zip_file *, int *, int *);
const char *zip_file_strerror(struct zip_file *);
struct zip_file *zip_fopen(struct zip *, const char *, int);
@@ -194,6 +197,7 @@ struct zip_source *zip_source_zip(struct zip *, struct zip *, int, int,
off_t, off_t);
int zip_stat(struct zip *, const char *, int, struct zip_stat *);
int zip_stat_index(struct zip *, int, int, struct zip_stat *);
+void zip_stat_init(struct zip_stat *);
const char *zip_strerror(struct zip *);
int zip_unchange(struct zip *, int);
int zip_unchange_all(struct zip *);
diff --git a/ext/zip/lib/zip_add_dir.c b/ext/zip/lib/zip_add_dir.c
new file mode 100644
index 000000000..957aaf1d2
--- /dev/null
+++ b/ext/zip/lib/zip_add_dir.c
@@ -0,0 +1,83 @@
+/*
+ $NiH: zip_add_dir.c,v 1.1 2006/10/03 12:23:13 dillo Exp $
+
+ zip_add_dir.c -- add directory
+ Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
+
+ This file is part of libzip, a library to manipulate ZIP archives.
+ The authors can be contacted at <nih@giga.or.at>
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ 3. The names of the authors may not be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "zip.h"
+#include "zipint.h"
+
+
+
+int
+zip_add_dir(struct zip *za, const char *name)
+{
+ int len, ret;
+ char *s;
+ struct zip_source *source;
+
+ if (name == NULL) {
+ _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
+ return -1;
+ }
+
+ s = NULL;
+ len = strlen(name);
+
+ if (name[len-1] != '/') {
+ if ((s=(char *)malloc(len+2)) == NULL) {
+ _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
+ return -1;
+ }
+ strcpy(s, name);
+ s[len] = '/';
+ s[len+1] = '\0';
+ }
+
+ if ((source=zip_source_buffer(za, NULL, 0, 0)) == NULL) {
+ free(s);
+ return -1;
+ }
+
+ ret = _zip_replace(za, -1, s ? s : name, source);
+
+ free(s);
+ if (ret < 0)
+ zip_source_free(source);
+
+ return ret;
+}
diff --git a/ext/zip/lib/zip_close.c b/ext/zip/lib/zip_close.c
index 3cb324d9c..e701321a8 100644
--- a/ext/zip/lib/zip_close.c
+++ b/ext/zip/lib/zip_close.c
@@ -247,7 +247,7 @@ zip_close(struct zip *za)
chmod(za->zn, 0666&~mask);
_zip_free(za);
-
+ free(temp);
return 0;
}
@@ -527,13 +527,14 @@ _zip_create_temp_output(struct zip *za, FILE **outp)
char *temp;
int tfd;
FILE *tfp;
+ int len = strlen(za->zn) + 8;
- if ((temp=(char *)malloc(strlen(za->zn)+8)) == NULL) {
+ if ((temp=(char *)malloc(len)) == NULL) {
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
return NULL;
}
- sprintf(temp, "%s.XXXXXX", za->zn);
+ snprintf(temp, len, "%s.XXXXXX", za->zn);
if ((tfd=mkstemp(temp)) == -1) {
_zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno);
@@ -548,6 +549,9 @@ _zip_create_temp_output(struct zip *za, FILE **outp)
free(temp);
return NULL;
}
+#ifdef PHP_WIN32
+ _setmode(_fileno(tfp), _O_BINARY );
+#endif
*outp = tfp;
return temp;
diff --git a/ext/zip/lib/zip_dirent.c b/ext/zip/lib/zip_dirent.c
index f0c988bc7..8423ad534 100644
--- a/ext/zip/lib/zip_dirent.c
+++ b/ext/zip/lib/zip_dirent.c
@@ -33,8 +33,7 @@
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
-
+#include "main/php_reentrancy.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -391,11 +390,11 @@ _zip_dirent_write(struct zip_dirent *zde, FILE *fp, int localp,
static time_t
_zip_d2u_time(int dtime, int ddate)
{
- struct tm *tm;
+ struct tm *tm, tmbuf;
time_t now;
now = time(NULL);
- tm = localtime(&now);
+ tm = php_localtime_r(&now, &tmbuf);
tm->tm_year = ((ddate>>9)&127) + 1980 - 1900;
tm->tm_mon = ((ddate>>5)&15) - 1;
@@ -520,9 +519,9 @@ _zip_write4(unsigned int i, FILE *fp)
static void
_zip_u2d_time(time_t time, unsigned short *dtime, unsigned short *ddate)
{
- struct tm *tm;
+ struct tm *tm, tmbuf;
- tm = localtime(&time);
+ tm = php_localtime_r(&time, &tmbuf);
*ddate = ((tm->tm_year+1900-1980)<<9) + ((tm->tm_mon+1)<<5)
+ tm->tm_mday;
*dtime = ((tm->tm_hour)<<11) + ((tm->tm_min)<<5)
diff --git a/ext/zip/lib/zip_error.c b/ext/zip/lib/zip_error.c
index 33a8f3374..aec1638de 100644
--- a/ext/zip/lib/zip_error.c
+++ b/ext/zip/lib/zip_error.c
@@ -2,7 +2,7 @@
$NiH: zip_error.c,v 1.7 2005/06/09 19:57:09 dillo Exp $
zip_error.c -- struct zip_error helper functions
- Copyright (C) 1999, 2003, 2004, 2005 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <nih@giga.or.at>
@@ -43,6 +43,15 @@
void
+_zip_error_clear(struct zip_error *err)
+{
+ err->zip_err = ZIP_ER_OK;
+ err->sys_err = 0;
+}
+
+
+
+void
_zip_error_copy(struct zip_error *dst, struct zip_error *src)
{
dst->zip_err = src->zip_err;
@@ -78,7 +87,7 @@ _zip_error_get(struct zip_error *err, int *zep, int *sep)
void
_zip_error_init(struct zip_error *err)
{
- err->zip_err = 0;
+ err->zip_err = ZIP_ER_OK;
err->sys_err = 0;
err->str = NULL;
}
diff --git a/ext/zip/lib/zip_error_clear.c b/ext/zip/lib/zip_error_clear.c
new file mode 100644
index 000000000..e3c81eb31
--- /dev/null
+++ b/ext/zip/lib/zip_error_clear.c
@@ -0,0 +1,47 @@
+/*
+ $NiH: zip_error_clear.c,v 1.1 2006/10/04 15:21:09 dillo Exp $
+
+ zip_error_clear.c -- clear zip error
+ Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
+
+ This file is part of libzip, a library to manipulate ZIP archives.
+ The authors can be contacted at <nih@giga.or.at>
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ 3. The names of the authors may not be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+
+#include "zip.h"
+#include "zipint.h"
+
+
+
+void
+zip_error_clear(struct zip *za)
+{
+ _zip_error_clear(&za->error);
+}
diff --git a/ext/zip/lib/zip_error_strerror.c b/ext/zip/lib/zip_error_strerror.c
index f14f7190e..e6eee081d 100644
--- a/ext/zip/lib/zip_error_strerror.c
+++ b/ext/zip/lib/zip_error_strerror.c
@@ -54,7 +54,7 @@ _zip_error_strerror(struct zip_error *err)
_zip_error_fini(err);
if (err->zip_err < 0 || err->zip_err >= _zip_nerr_str) {
- sprintf(buf, "Unknown error %d", err->zip_err);
+ snprintf(buf, sizeof(buf), "Unknown error %d", err->zip_err);
zs = NULL;
ss = buf;
}
@@ -78,11 +78,11 @@ _zip_error_strerror(struct zip_error *err)
if (ss == NULL)
return zs;
else {
- if ((s=(char *)malloc(strlen(ss)
- + (zs ? strlen(zs)+2 : 0) + 1)) == NULL)
+ int l = strlen(ss) + (zs ? strlen(zs)+2 : 0) + 1;
+ if ((s=(char *)malloc(l)) == NULL)
return _zip_err_str[ZIP_ER_MEMORY];
- sprintf(s, "%s%s%s",
+ snprintf(s, l, "%s%s%s",
(zs ? zs : ""),
(zs ? ": " : ""),
ss);
diff --git a/ext/zip/lib/zip_fclose.c b/ext/zip/lib/zip_fclose.c
index cf4f35c71..c0105a929 100644
--- a/ext/zip/lib/zip_fclose.c
+++ b/ext/zip/lib/zip_fclose.c
@@ -52,13 +52,15 @@ zip_fclose(struct zip_file *zf)
free(zf->buffer);
free(zf->zstr);
- for (i=0; i<zf->za->nfile; i++) {
- if (zf->za->file[i] == zf) {
- zf->za->file[i] = zf->za->file[zf->za->nfile-1];
- zf->za->nfile--;
- break;
+ if (zf->za) {
+ for (i=0; i<zf->za->nfile; i++) {
+ if (zf->za->file[i] == zf) {
+ zf->za->file[i] = zf->za->file[zf->za->nfile-1];
+ zf->za->nfile--;
+ break;
+ }
+ }
}
- }
ret = 0;
if (zf->error.zip_err)
diff --git a/ext/zip/lib/zip_file_error_clear.c b/ext/zip/lib/zip_file_error_clear.c
new file mode 100644
index 000000000..86ed68f27
--- /dev/null
+++ b/ext/zip/lib/zip_file_error_clear.c
@@ -0,0 +1,47 @@
+/*
+ $NiH: zip_file_error_clear.c,v 1.4 2006/10/04 18:37:54 wiz Exp $
+
+ zip_file_error_clear.c -- clear zip file error
+ Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
+
+ This file is part of libzip, a library to manipulate ZIP archives.
+ The authors can be contacted at <nih@giga.or.at>
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ 3. The names of the authors may not be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+
+#include "zip.h"
+#include "zipint.h"
+
+
+
+void
+zip_file_error_clear(struct zip_file *zf)
+{
+ _zip_error_clear(&zf->error);
+}
diff --git a/ext/zip/lib/zip_free.c b/ext/zip/lib/zip_free.c
index cbead2a6b..c78697d25 100644
--- a/ext/zip/lib/zip_free.c
+++ b/ext/zip/lib/zip_free.c
@@ -59,6 +59,9 @@ _zip_free(struct zip *za)
if (za->zp)
fclose(za->zp);
+ if (za->ch_comment)
+ free(za->ch_comment);
+
_zip_cdir_free(za->cdir);
if (za->entry) {
diff --git a/ext/zip/lib/zip_get_archive_comment.c b/ext/zip/lib/zip_get_archive_comment.c
index 40feb4eba..7844c5e19 100644
--- a/ext/zip/lib/zip_get_archive_comment.c
+++ b/ext/zip/lib/zip_get_archive_comment.c
@@ -47,7 +47,7 @@ zip_get_archive_comment(struct zip *za, int *lenp, int flags)
|| (za->ch_comment_len == -1)) {
if (za->cdir) {
if (lenp != NULL)
- *lenp = za->cdir->comment_len;
+ *lenp = za->cdir->comment_len;
return za->cdir->comment;
}
}
diff --git a/ext/zip/lib/zip_open.c b/ext/zip/lib/zip_open.c
index 0a14abda5..60526e8c9 100644
--- a/ext/zip/lib/zip_open.c
+++ b/ext/zip/lib/zip_open.c
@@ -2,7 +2,7 @@
$NiH: zip_open.c,v 1.38 2006/05/04 00:01:26 dillo Exp $
zip_open.c -- open zip archive
- Copyright (C) 1999-2006 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <nih@giga.or.at>
@@ -100,7 +100,6 @@ zip_open(const char *fn, int flags, int *zep)
return NULL;
}
-
/* ZIP_CREATE gets ignored if file exists and not ZIP_EXCL,
just like open() */
if ((fp=fopen(fn, "rb")) == NULL) {
@@ -108,6 +107,10 @@ zip_open(const char *fn, int flags, int *zep)
return NULL;
}
+#ifdef PHP_WIN32
+ _setmode(_fileno(fp), _O_BINARY );
+#endif
+
clearerr(fp);
fseek(fp, 0, SEEK_END);
len = ftell(fp);
diff --git a/ext/zip/lib/zip_set_archive_comment.c b/ext/zip/lib/zip_set_archive_comment.c
index 51a8416da..b0929e56b 100644
--- a/ext/zip/lib/zip_set_archive_comment.c
+++ b/ext/zip/lib/zip_set_archive_comment.c
@@ -60,7 +60,7 @@ zip_set_archive_comment(struct zip *za, const char *comment, int len)
else
tmpcom = NULL;
- free(za->ch_comment);
+ if (za->ch_comment) free(za->ch_comment);
za->ch_comment = tmpcom;
za->ch_comment_len = len;
diff --git a/ext/zip/lib/zip_source_buffer.c b/ext/zip/lib/zip_source_buffer.c
index ada9ae85f..a01f18d3f 100644
--- a/ext/zip/lib/zip_source_buffer.c
+++ b/ext/zip/lib/zip_source_buffer.c
@@ -2,7 +2,7 @@
$NiH: zip_source_buffer.c,v 1.8 2006/04/23 14:50:49 wiz Exp $
zip_source_buffer.c -- create zip data source from buffer
- Copyright (C) 1999, 2003, 2004, 2005 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <nih@giga.or.at>
@@ -125,11 +125,9 @@ read_data(void *state, void *data, size_t len, enum zip_source_cmd cmd)
st = (struct zip_stat *)data;
+ zip_stat_init(st);
st->mtime = z->mtime;
- st->crc = 0;
st->size = z->end - z->data;
- st->comp_size = -1;
- st->comp_method = ZIP_CM_STORE;
return sizeof(*st);
}
diff --git a/ext/zip/lib/zip_source_file.c b/ext/zip/lib/zip_source_file.c
index f06b32fec..d635da342 100644
--- a/ext/zip/lib/zip_source_file.c
+++ b/ext/zip/lib/zip_source_file.c
@@ -62,6 +62,10 @@ zip_source_file(struct zip *za, const char *fname, off_t start, off_t len)
return NULL;
}
+#ifdef PHP_WIN32
+ _setmode(_fileno(fp), _O_BINARY );
+#endif
+
if ((zs=zip_source_filep(za, fp, start, len)) == NULL) {
fclose(fp);
return NULL;
diff --git a/ext/zip/lib/zip_source_filep.c b/ext/zip/lib/zip_source_filep.c
index 9c7383cf2..efc702686 100644
--- a/ext/zip/lib/zip_source_filep.c
+++ b/ext/zip/lib/zip_source_filep.c
@@ -2,7 +2,7 @@
$NiH: zip_source_filep.c,v 1.6 2005/06/09 19:57:10 dillo Exp $
zip_source_filep.c -- create data source from FILE *
- Copyright (C) 1999, 2003, 2004, 2005 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <nih@giga.or.at>
@@ -138,24 +138,20 @@ read_file(void *state, void *data, size_t len, enum zip_source_cmd cmd)
if (len < sizeof(*st))
return -1;
- st = (struct zip_stat *)data;
-
if (fstat(fileno(z->f), &fst) != 0) {
z->e[0] = ZIP_ER_READ; /* best match */
z->e[1] = errno;
return -1;
}
+ st = (struct zip_stat *)data;
+
+ zip_stat_init(st);
st->mtime = fst.st_mtime;
- st->crc = 0;
if (z->len != -1)
st->size = z->len;
else if ((fst.st_mode&S_IFMT) == S_IFREG)
st->size = fst.st_size;
- else
- st->size = -1;
- st->comp_size = -1;
- st->comp_method = ZIP_CM_STORE;
return sizeof(*st);
}
diff --git a/ext/zip/lib/zip_stat_index.c b/ext/zip/lib/zip_stat_index.c
index 837d63907..bab79a74b 100644
--- a/ext/zip/lib/zip_stat_index.c
+++ b/ext/zip/lib/zip_stat_index.c
@@ -67,8 +67,7 @@ zip_stat_index(struct zip *za, int index, int flags, struct zip_stat *st)
_zip_error_set(&za->error, ZIP_ER_INVAL, 0);
return -1;
}
-
- st->index = index;
+
st->crc = za->cdir->entry[index].crc;
st->size = za->cdir->entry[index].uncomp_size;
st->mtime = za->cdir->entry[index].last_mod;
@@ -87,6 +86,7 @@ zip_stat_index(struct zip *za, int index, int flags, struct zip_stat *st)
/* st->bitflags = za->cdir->entry[index].bitflags; */
}
+ st->index = index;
st->name = name;
return 0;
diff --git a/ext/zip/lib/zip_stat_init.c b/ext/zip/lib/zip_stat_init.c
new file mode 100644
index 000000000..7ab0f4da7
--- /dev/null
+++ b/ext/zip/lib/zip_stat_init.c
@@ -0,0 +1,53 @@
+/*
+ $NiH: zip_stat_init.c,v 1.1 2006/10/31 12:03:04 dillo Exp $
+
+ zip_stat_init.c -- initialize struct zip_stat.
+ Copyright (C) 2006 Dieter Baron and Thomas Klausner
+
+ This file is part of libzip, a library to manipulate ZIP archives.
+ The authors can be contacted at <nih@giga.or.at>
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ 3. The names of the authors may not be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+
+#include "zipint.h"
+
+
+
+void
+zip_stat_init(struct zip_stat *st)
+{
+ st->name = NULL;
+ st->index = -1;
+ st->crc = 0;
+ st->mtime = (time_t)-1;
+ st->size = -1;
+ st->comp_size = -1;
+ st->comp_method = ZIP_CM_STORE;
+ st->encryption_method = ZIP_EM_NONE;
+}
diff --git a/ext/zip/lib/zipint.h b/ext/zip/lib/zipint.h
index 9efaf06a3..ebf2743f9 100644
--- a/ext/zip/lib/zipint.h
+++ b/ext/zip/lib/zipint.h
@@ -199,6 +199,7 @@ void _zip_entry_free(struct zip_entry *);
void _zip_entry_init(struct zip *, int);
struct zip_entry *_zip_entry_new(struct zip *);
+void _zip_error_clear(struct zip_error *);
void _zip_error_copy(struct zip_error *, struct zip_error *);
void _zip_error_fini(struct zip_error *);
void _zip_error_get(struct zip_error *, int *, int *);