]> granicus.if.org Git - php/commitdiff
- restore fix for binary mode on win (regression introduced in 5.2.8)
authorPierre Joye <pajoye@php.net>
Thu, 1 Jan 2009 19:32:24 +0000 (19:32 +0000)
committerPierre Joye <pajoye@php.net>
Thu, 1 Jan 2009 19:32:24 +0000 (19:32 +0000)
ext/zip/lib/zip_close.c

index c0df23a8742bd08cb5935e97a38026835a977f43..289ca7afb34959d50dba66fa01aa67476aac84e5 100644 (file)
@@ -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) {
        _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;