pajoye Sun Jun 3 19:47:17 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zip php_zip.c Log: - PECL #11216, addEmptyDir crashes if the directory already exists http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.33&r2=1.1.2.34&diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.33 php-src/ext/zip/php_zip.c:1.1.2.34 --- php-src/ext/zip/php_zip.c:1.1.2.33 Sat May 19 22:25:11 2007 +++ php-src/ext/zip/php_zip.c Sun Jun 3 19:47:17 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_zip.c,v 1.1.2.33 2007/05/19 22:25:11 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.34 2007/06/03 19:47:17 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -985,6 +985,9 @@ zval *this = getThis(); char *dirname; int dirname_len; + int idx; + struct zip_stat sb; + char *s; if (!this) { RETURN_FALSE; @@ -996,13 +999,30 @@ &dirname, &dirname_len) == FAILURE) { return; } + if (dirname_len<1) { RETURN_FALSE; } - if (zip_add_dir(intern, (const char *)dirname) < 0) { + if (dirname[dirname_len-1] != '/') { + + s=(char *)emalloc(dirname_len+2); + strcpy(s, dirname); + s[dirname_len] = '/'; + s[dirname_len+1] = '\0'; + } else { + s = dirname; + } + + idx = zip_stat(intern, s, 0, &sb); + if (idx >= 0) { + RETURN_FALSE; + } + + if (zip_add_dir(intern, (const char *)s) == -1) { RETURN_FALSE; } + RETURN_TRUE; } /* }}} */ @@ -2022,7 +2042,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "Zip", "enabled"); - php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 1.1.2.33 2007/05/19 22:25:11 pajoye Exp $"); + php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 1.1.2.34 2007/06/03 19:47:17 pajoye Exp $"); php_info_print_table_row(2, "Zip version", "2.0.0"); php_info_print_table_row(2, "Libzip version", "0.7.1");
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php