]> granicus.if.org Git - php/commitdiff
Fixed snprintf() usage
authorIlia Alshanetsky <iliaa@php.net>
Sat, 24 Feb 2007 16:23:10 +0000 (16:23 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sat, 24 Feb 2007 16:23:10 +0000 (16:23 +0000)
ext/zip/lib/zip_close.c

index a5a1bc094deef6bf8bfe803cee1ca44b0890a776..e701321a8199c5b80c84603b325578e5dc6ed2d2 100644 (file)
@@ -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;
     }
 
-    snprintf(temp, sizeof(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);