cellog Sun Oct 26 05:49:10 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/phar phar.c phar_object.c util.c
Log:
fix several errors found by valgrind
1 - entry metadata not properly processed or retrieved from cached phars
2 - copy on write was using a void return value instead of int, a dangerous
oversight in phar_update_cached_entry
3 - metadata creation in entries for cached phars was causing an invalid read
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar.c?r1=1.370.2.51&r2=1.370.2.52&diff_format=u
Index: php-src/ext/phar/phar.c
diff -u php-src/ext/phar/phar.c:1.370.2.51 php-src/ext/phar/phar.c:1.370.2.52
--- php-src/ext/phar/phar.c:1.370.2.51 Sun Oct 12 21:09:22 2008
+++ php-src/ext/phar/phar.c Sun Oct 26 05:49:09 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar.c,v 1.370.2.51 2008/10/12 21:09:22 tony2001 Exp $ */
+/* $Id: phar.c,v 1.370.2.52 2008/10/26 05:49:09 cellog Exp $ */
#define PHAR_MAIN 1
#include "phar_internal.h"
@@ -1114,7 +1114,9 @@
}
if (entry.is_persistent) {
- if (phar_parse_metadata(&buffer, &entry.metadata, 0
TSRMLS_CC) == FAILURE) {
+ PHAR_GET_32(buffer, entry.metadata_len);
+ if (!entry.metadata_len) buffer -= 4;
+ if (phar_parse_metadata(&buffer, &entry.metadata,
entry.metadata_len TSRMLS_CC) == FAILURE) {
pefree(entry.filename, entry.is_persistent);
MAPPHAR_FAIL("unable to read file metadata in
.phar file \"%s\"");
}
@@ -3622,7 +3624,7 @@
php_info_print_table_header(2, "Phar: PHP Archive support", "enabled");
php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION);
php_info_print_table_row(2, "Phar API version", PHP_PHAR_API_VERSION);
- php_info_print_table_row(2, "CVS revision", "$Revision: 1.370.2.51 $");
+ php_info_print_table_row(2, "CVS revision", "$Revision: 1.370.2.52 $");
php_info_print_table_row(2, "Phar-based phar archives", "enabled");
php_info_print_table_row(2, "Tar-based phar archives", "enabled");
php_info_print_table_row(2, "ZIP-based phar archives", "enabled");
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar_object.c?r1=1.266.2.53&r2=1.266.2.54&diff_format=u
Index: php-src/ext/phar/phar_object.c
diff -u php-src/ext/phar/phar_object.c:1.266.2.53
php-src/ext/phar/phar_object.c:1.266.2.54
--- php-src/ext/phar/phar_object.c:1.266.2.53 Fri Oct 24 14:35:37 2008
+++ php-src/ext/phar/phar_object.c Sun Oct 26 05:49:09 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar_object.c,v 1.266.2.53 2008/10/24 14:35:37 felipe Exp $ */
+/* $Id: phar_object.c,v 1.266.2.54 2008/10/26 05:49:09 cellog Exp $ */
#include "phar_internal.h"
#include "func_interceptors.h"
@@ -4583,6 +4583,15 @@
PHAR_ENTRY_OBJECT();
if (entry_obj->ent.entry->metadata) {
+ if (entry_obj->ent.entry->is_persistent) {
+ zval *ret;
+ char *buf = estrndup((char *)
entry_obj->ent.entry->metadata, entry_obj->ent.entry->metadata_len);
+ /* assume success, we would have failed before */
+ phar_parse_metadata(&buf, &ret,
entry_obj->ent.entry->metadata_len TSRMLS_CC);
+ efree(buf);
+ RETURN_ZVAL(ret, 0, 1);
+ return;
+ }
RETURN_ZVAL(entry_obj->ent.entry->metadata, 1, 0);
}
}
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/util.c?r1=1.55.2.38&r2=1.55.2.39&diff_format=u
Index: php-src/ext/phar/util.c
diff -u php-src/ext/phar/util.c:1.55.2.38 php-src/ext/phar/util.c:1.55.2.39
--- php-src/ext/phar/util.c:1.55.2.38 Sun Oct 12 19:40:11 2008
+++ php-src/ext/phar/util.c Sun Oct 26 05:49:09 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: util.c,v 1.55.2.38 2008/10/12 19:40:11 cellog Exp $ */
+/* $Id: util.c,v 1.55.2.39 2008/10/26 05:49:09 cellog Exp $ */
#include "phar_internal.h"
@@ -2198,7 +2198,7 @@
}
/* }}} */
-static void phar_update_cached_entry(void *data, void *argument) /* {{{ */
+static int phar_update_cached_entry(void *data, void *argument) /* {{{ */
{
phar_entry_info *entry = (phar_entry_info *)data;
TSRMLS_FETCH();
@@ -2221,7 +2221,7 @@
if (entry->metadata_len) {
char *buf = estrndup((char *) entry->metadata,
entry->metadata_len);
/* assume success, we would have failed before */
- phar_parse_metadata((char **) &entry->metadata,
&entry->metadata, entry->metadata_len TSRMLS_CC);
+ phar_parse_metadata((char **) &buf, &entry->metadata,
entry->metadata_len TSRMLS_CC);
efree(buf);
} else {
zval *t;
@@ -2239,6 +2239,7 @@
entry->metadata_str.len = 0;
}
}
+ return ZEND_HASH_APPLY_KEEP;
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php