summaryrefslogtreecommitdiff
path: root/ext/zip/lib/zip_close.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/zip/lib/zip_close.c')
-rw-r--r--ext/zip/lib/zip_close.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/ext/zip/lib/zip_close.c b/ext/zip/lib/zip_close.c
index d9fc6eea4..bc640c77b 100644
--- a/ext/zip/lib/zip_close.c
+++ b/ext/zip/lib/zip_close.c
@@ -175,6 +175,7 @@ zip_close(struct zip *za)
de.filename = strdup("-");
de.filename_len = 1;
cd->entry[j].filename = "-";
+ cd->entry[j].filename_len = 1;
}
else {
de.filename = strdup(za->cdir->entry[i].filename);
@@ -195,13 +196,15 @@ zip_close(struct zip *za)
error = 1;
break;
}
+ memcpy(cd->entry+j, za->cdir->entry+i, sizeof(cd->entry[j]));
+
if (de.bitflags & ZIP_GPBF_DATA_DESCRIPTOR) {
de.crc = za->cdir->entry[i].crc;
de.comp_size = za->cdir->entry[i].comp_size;
de.uncomp_size = za->cdir->entry[i].uncomp_size;
de.bitflags &= ~ZIP_GPBF_DATA_DESCRIPTOR;
- }
- memcpy(cd->entry+j, za->cdir->entry+i, sizeof(cd->entry[j]));
+ cd->entry[j].bitflags &= ~ZIP_GPBF_DATA_DESCRIPTOR;
+ }
}
if (za->entry[i].ch_filename) {
@@ -229,11 +232,10 @@ zip_close(struct zip *za)
zs = NULL;
if (!ZIP_ENTRY_DATA_CHANGED(za->entry+i)) {
- if ((zs=zip_source_zip(za, za, i, ZIP_FL_RECOMPRESS, 0, -1))
- == NULL) {
- error = 1;
- break;
- }
+ if ((zs=zip_source_zip(za, za, i, ZIP_FL_RECOMPRESS, 0, -1)) == NULL) {
+ error = 1;
+ break;
+ }
}
if (add_data(za, zs ? zs : za->entry[i].source, &de, out) < 0) {
@@ -286,27 +288,27 @@ zip_close(struct zip *za)
return -1;
}
- if (za->zp) {
- fclose(za->zp);
- za->zp = NULL;
- reopen_on_error = 1;
+ if (za->zp) {
+ fclose(za->zp);
+ za->zp = NULL;
+ reopen_on_error = 1;
}
if (_zip_rename(temp, za->zn) != 0) {
- _zip_error_set(&za->error, ZIP_ER_RENAME, errno);
- remove(temp);
- free(temp);
- if (reopen_on_error) {
- /* ignore errors, since we're already in an error case */
- za->zp = fopen(za->zn, "rb");
+ _zip_error_set(&za->error, ZIP_ER_RENAME, errno);
+ remove(temp);
+ free(temp);
+ if (reopen_on_error) {
+ /* ignore errors, since we're already in an error case */
+ za->zp = fopen(za->zn, "rb");
+ }
+ return -1;
}
- return -1;
- }
mask = umask(0);
umask(mask);
chmod(za->zn, 0666&~mask);
_zip_free(za);
- free(temp);
+ free(temp);
return 0;
}