summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2009-01-02 00:04:33 +0000
committerPierre Joye <pajoye@php.net>2009-01-02 00:04:33 +0000
commit14f2f4148c689daca1f77e95be98617d6552dd0c (patch)
tree1c1f54af4ca5f1f7cefcc31810ca05f6e5c53eba
parent7b5baaac9bbd7504e73275d82f8cd0ecbac14329 (diff)
downloadphp-git-14f2f4148c689daca1f77e95be98617d6552dd0c.tar.gz
- MFB: restore fix for binary mode on win (regression introduced in 5.2.8)
-rw-r--r--ext/zip/lib/zip_close.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/zip/lib/zip_close.c b/ext/zip/lib/zip_close.c
index 1ebdb7fc71..d9fc6eea43 100644
--- a/ext/zip/lib/zip_close.c
+++ b/ext/zip/lib/zip_close.c
@@ -636,13 +636,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);
@@ -657,6 +658,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;