sfox Wed May 14 21:29:51 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/phar dirstream.c func_interceptors.c phar.c
phar_internal.h phar_object.c shortarc.php
stream.c stub.h util.c
/php-src/ext/phar/tests/files phar_test.inc
/php-src/ext/phar/tests phar_commitwrite.phpt
phar_convert_repeated.phpt
phar_create_in_cwd.phpt
phar_createdefaultstub.phpt
phar_setdefaultstub.phpt
/php-src/ext/phar/tests/tar phar_convert_phar.phpt
phar_convert_phar2.phpt
/php-src/ext/phar/tests/zip phar_convert_phar.phpt
Log:
- MFH
- Make internal code forward-compatible. This included a binary cast in the
default stub, hence test updates.
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/dirstream.c?r1=1.26&r2=1.26.2.1&diff_format=u
Index: php-src/ext/phar/dirstream.c
diff -u php-src/ext/phar/dirstream.c:1.26 php-src/ext/phar/dirstream.c:1.26.2.1
--- php-src/ext/phar/dirstream.c:1.26 Wed May 7 05:38:29 2008
+++ php-src/ext/phar/dirstream.c Wed May 14 21:29:50 2008
@@ -94,7 +94,8 @@
{
size_t to_read;
HashTable *data = (HashTable *)stream->abstract;
- char *key;
+ phar_zstr key;
+ char *str_key;
uint keylen;
ulong unused;
@@ -104,13 +105,14 @@
if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(data, &key,
&keylen, &unused, 0, NULL)) {
return 0;
}
+ PHAR_STR(key, str_key);
zend_hash_move_forward(data);
to_read = MIN(keylen, count);
if (to_read == 0 || count < keylen) {
return 0;
}
memset(buf, 0, sizeof(php_stream_dirent));
- memcpy(((php_stream_dirent *) buf)->d_name, key, to_read);
+ memcpy(((php_stream_dirent *) buf)->d_name, str_key, to_read);
((php_stream_dirent *) buf)->d_name[to_read + 1] = '\0';
return sizeof(php_stream_dirent);
@@ -186,10 +188,11 @@
{
HashTable *data;
int dirlen = strlen(dir);
- char *save, *found, *key;
+ phar_zstr key;
+ char *entry, *found, *save, *str_key;
uint keylen;
ulong unused;
- char *entry;
+
ALLOC_HASHTABLE(data);
zend_hash_init(data, 64, zend_get_hash_value, NULL, 0);
@@ -203,8 +206,9 @@
if (HASH_KEY_NON_EXISTANT ==
zend_hash_get_current_key_ex(manifest, &key, &keylen, &unused, 0, NULL)) {
break;
}
+ PHAR_STR(key, str_key);
if (keylen <= (uint)dirlen) {
- if (keylen < (uint)dirlen || !strncmp(key, dir,
dirlen)) {
+ if (keylen < (uint)dirlen || !strncmp(str_key, dir,
dirlen)) {
if (SUCCESS !=
zend_hash_move_forward(manifest)) {
break;
}
@@ -213,27 +217,27 @@
}
if (*dir == '/') {
/* root directory */
- if (NULL != (found = (char *) memchr(key, '/',
keylen))) {
+ if (NULL != (found = (char *) memchr(str_key, '/',
keylen))) {
/* the entry has a path separator and is a
subdirectory */
- entry = (char *) safe_emalloc(found - key, 1,
1);
- memcpy(entry, key, found - key);
- keylen = found - key;
+ entry = (char *) safe_emalloc(found - str_key,
1, 1);
+ memcpy(entry, str_key, found - str_key);
+ keylen = found - str_key;
entry[keylen] = '\0';
} else {
entry = (char *) safe_emalloc(keylen, 1, 1);
- memcpy(entry, key, keylen);
+ memcpy(entry, str_key, keylen);
entry[keylen] = '\0';
}
goto PHAR_ADD_ENTRY;
} else {
- if (0 != memcmp(key, dir, dirlen)) {
+ if (0 != memcmp(str_key, dir, dirlen)) {
/* entry in directory not found */
if (SUCCESS !=
zend_hash_move_forward(manifest)) {
break;
}
continue;
} else {
- if (key[dirlen] != '/') {
+ if (str_key[dirlen] != '/') {
if (SUCCESS !=
zend_hash_move_forward(manifest)) {
break;
}
@@ -241,7 +245,7 @@
}
}
}
- save = key;
+ save = str_key;
save += dirlen + 1; /* seek to just past the path separator */
if (NULL != (found = (char *) memchr(save, '/', keylen - dirlen
- 1))) {
/* is subdirectory */
@@ -289,7 +293,8 @@
{
php_url *resource = NULL;
php_stream *ret;
- char *internal_file, *key, *error;
+ char *internal_file, *error, *str_key;
+ phar_zstr key;
uint keylen;
ulong unused;
phar_archive_data *phar;
@@ -367,7 +372,8 @@
if (HASH_KEY_NON_EXISTANT !=
zend_hash_get_current_key_ex(
&phar->manifest, &key, &keylen,
&unused, 0, NULL)) {
- if (keylen > (uint)i_len && 0 == memcmp(key,
internal_file, i_len)) {
+ PHAR_STR(key, str_key);
+ if (keylen > (uint)i_len && 0 ==
memcmp(str_key, internal_file, i_len)) {
/* directory found */
internal_file = estrndup(internal_file,
i_len);
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/func_interceptors.c?r1=1.20&r2=1.20.2.1&diff_format=u
Index: php-src/ext/phar/func_interceptors.c
diff -u php-src/ext/phar/func_interceptors.c:1.20
php-src/ext/phar/func_interceptors.c:1.20.2.1
--- php-src/ext/phar/func_interceptors.c:1.20 Sun May 11 21:30:04 2008
+++ php-src/ext/phar/func_interceptors.c Wed May 14 21:29:50 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: func_interceptors.c,v 1.20 2008/05/11 21:30:04 cellog Exp $ */
+/* $Id: func_interceptors.c,v 1.20.2.1 2008/05/14 21:29:50 sfox Exp $ */
#include "phar_internal.h"
@@ -655,7 +655,8 @@
goto stat_entry;
} else {
phar_archive_data *phar = *pphar;
- char *key;
+ phar_zstr key;
+ char *str_key;
uint keylen;
ulong unused;
@@ -667,11 +668,12 @@
if (HASH_KEY_NON_EXISTANT !=
zend_hash_get_current_key_ex(
&phar->manifest, &key, &keylen, &unused, 0, NULL)) {
- if (!memcmp(actual,
key, actual_len)) {
+ PHAR_STR(key, str_key);
+ if (!memcmp(actual,
str_key, actual_len)) {
efree(save2);
efree(entry);
/* directory
found, all dirs have the same stat */
- if
(key[actual_len] == '/') {
+ if
(str_key[actual_len] == '/') {
sb.st_size = 0;
sb.st_mode = 0777;
sb.st_mode |= S_IFDIR; /* regular directory */
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar.c?r1=1.370.2.1&r2=1.370.2.2&diff_format=u
Index: php-src/ext/phar/phar.c
diff -u php-src/ext/phar/phar.c:1.370.2.1 php-src/ext/phar/phar.c:1.370.2.2
--- php-src/ext/phar/phar.c:1.370.2.1 Tue May 13 14:11:24 2008
+++ php-src/ext/phar/phar.c Wed May 14 21:29:50 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar.c,v 1.370.2.1 2008/05/13 14:11:24 sfox Exp $ */
+/* $Id: phar.c,v 1.370.2.2 2008/05/14 21:29:50 sfox Exp $ */
#define PHAR_MAIN 1
#include "phar_internal.h"
@@ -817,7 +817,7 @@
register_alias = 1;
temp_alias = 1;
}
-
+
/* we have 5 32-bit items plus 1 byte at least */
if (manifest_count > ((manifest_len - 10 - tmp_len) / (5 * 4 + 1))) {
/* prevent serious memory issues */
@@ -1592,7 +1592,8 @@
return FAILURE;
}
} else {
- char *key;
+ phar_zstr key;
+ char *str_key;
uint keylen;
ulong unused;
@@ -1602,11 +1603,13 @@
break;
}
+ PHAR_STR(key, str_key);
+
if (keylen > (uint) filename_len) {
zend_hash_move_forward(&(PHAR_GLOBALS->phar_fname_map));
continue;
}
- if (!memcmp(filename, key, keylen) &&
((uint)filename_len == keylen
+ if (!memcmp(filename, str_key, keylen) &&
((uint)filename_len == keylen
|| filename[keylen] == '/' ||
filename[keylen] == '\0')) {
if (FAILURE ==
zend_hash_get_current_data(&(PHAR_GLOBALS->phar_fname_map), (void **) &pphar)) {
break;
@@ -2847,7 +2850,7 @@
}
} else if (phar->flags & PHAR_FILE_COMPRESSION_MASK) {
/* compressed phar */
-#if PHP_VERSION_ID >= 50300 && PHP_VERSION_ID < 60000
+#if PHP_VERSION_ID >= 50300
file_handle->type = ZEND_HANDLE_STREAM;
file_handle->free_filename = 0;
file_handle->handle.stream.handle = phar;
@@ -3023,7 +3026,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.1 $");
+ php_info_print_table_row(2, "CVS revision", "$Revision: 1.370.2.2 $");
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_internal.h?r1=1.109&r2=1.109.2.1&diff_format=u
Index: php-src/ext/phar/phar_internal.h
diff -u php-src/ext/phar/phar_internal.h:1.109
php-src/ext/phar/phar_internal.h:1.109.2.1
--- php-src/ext/phar/phar_internal.h:1.109 Wed May 7 17:24:21 2008
+++ php-src/ext/phar/phar_internal.h Wed May 14 21:29:51 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar_internal.h,v 1.109 2008/05/07 17:24:21 cellog Exp $ */
+/* $Id: phar_internal.h,v 1.109.2.1 2008/05/14 21:29:51 sfox Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -354,8 +354,17 @@
# endif
#endif
-BEGIN_EXTERN_C()
+#if PHP_VERSION_ID >= 60000
+typedef zstr phar_zstr;
+#define PHAR_STR(a, b) \
+ spprintf(&b, 0, "%r", a.s);
+#else
+typedef char *phar_zstr;
+#define PHAR_STR(a, b) \
+ b = a;
+#endif
+BEGIN_EXTERN_C()
#ifdef PHP_WIN32
char *tsrm_strtok_r(char *s, const char *delim, char **last);
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar_object.c?r1=1.266&r2=1.266.2.1&diff_format=u
Index: php-src/ext/phar/phar_object.c
diff -u php-src/ext/phar/phar_object.c:1.266
php-src/ext/phar/phar_object.c:1.266.2.1
--- php-src/ext/phar/phar_object.c:1.266 Mon May 12 20:42:06 2008
+++ php-src/ext/phar/phar_object.c Wed May 14 21:29:51 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar_object.c,v 1.266 2008/05/12 20:42:06 cellog Exp $ */
+/* $Id: phar_object.c,v 1.266.2.1 2008/05/14 21:29:51 sfox Exp $ */
#include "phar_internal.h"
#include "func_interceptors.h"
@@ -778,7 +778,7 @@
mime.len = Z_STRLEN_PP(val); \
} \
mime.type = ret; \
- zend_hash_update(&mimetypes, key, keylen-1, (void *)&mime,
sizeof(phar_mime_type), NULL);
+ zend_hash_update(&mimetypes, str_key, keylen-1, (void *)&mime,
sizeof(phar_mime_type), NULL);
if (mimeoverride) {
if (!zend_hash_num_elements(Z_ARRVAL_P(mimeoverride))) {
@@ -786,9 +786,11 @@
}
for
(zend_hash_internal_pointer_reset(Z_ARRVAL_P(mimeoverride)); SUCCESS ==
zend_hash_has_more_elements(Z_ARRVAL_P(mimeoverride));
zend_hash_move_forward(Z_ARRVAL_P(mimeoverride))) {
zval **val;
- char *key;
+ phar_zstr key;
+ char *str_key;
uint keylen;
ulong intkey;
+
if (HASH_KEY_IS_LONG ==
zend_hash_get_current_key_ex(Z_ARRVAL_P(mimeoverride), &key, &keylen, &intkey,
0, NULL)) {
zend_throw_exception_ex(phar_ce_PharException,
0 TSRMLS_CC, "Key of MIME type overrides array must be a file extension, was
\"%d\"", intkey);
phar_entry_delref(phar TSRMLS_CC);
@@ -797,8 +799,11 @@
#endif
RETURN_FALSE;
}
+
+ PHAR_STR(key, str_key);
+
if (FAILURE ==
zend_hash_get_current_data(Z_ARRVAL_P(mimeoverride), (void **) &val)) {
- zend_throw_exception_ex(phar_ce_PharException,
0 TSRMLS_CC, "Failed to retrieve Mime type for extension \"%s\"", key);
+ zend_throw_exception_ex(phar_ce_PharException,
0 TSRMLS_CC, "Failed to retrieve Mime type for extension \"%s\"", str_key);
phar_entry_delref(phar TSRMLS_CC);
#ifdef PHP_WIN32
efree(fname);
@@ -1114,11 +1119,8 @@
return;
}
-#if PHP_VERSION_ID >= 60000
- objname = phar_obj->std.ce->name.s;
-#else
- objname = phar_obj->std.ce->name;
-#endif
+ PHAR_STR(phar_obj->std.ce->name, objname);
+
if (!strncmp(objname, "PharData", 8)) {
is_data = 1;
} else {
@@ -1315,7 +1317,9 @@
phar_entry_data *data;
php_stream *fp;
long contents_len;
- char *fname, *error, *str_key, *base = p_obj->b, *opened, *save = NULL,
*temp = NULL;
+ char *fname, *error, *base = p_obj->b, *opened, *save = NULL, *temp =
NULL;
+ phar_zstr key;
+ char *str_key;
zend_class_entry *ce = p_obj->c;
phar_archive_object *phar_obj = p_obj->p;
char *str = "[stream]";
@@ -1339,10 +1343,14 @@
return ZEND_HASH_APPLY_STOP;
}
if (iter->funcs->get_current_key) {
- key_type = iter->funcs->get_current_key(iter,
&str_key, &str_key_len, &int_key TSRMLS_CC);
+ key_type = iter->funcs->get_current_key(iter,
&key, &str_key_len, &int_key TSRMLS_CC);
+
if (EG(exception)) {
return ZEND_HASH_APPLY_STOP;
}
+
+ PHAR_STR(key, str_key);
+
if (key_type == HASH_KEY_IS_LONG) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator
%s returned an invalid key (must return a string)", ce->name);
return ZEND_HASH_APPLY_STOP;
@@ -1438,10 +1446,14 @@
}
} else {
if (iter->funcs->get_current_key) {
- key_type = iter->funcs->get_current_key(iter, &str_key,
&str_key_len, &int_key TSRMLS_CC);
+ key_type = iter->funcs->get_current_key(iter, &key,
&str_key_len, &int_key TSRMLS_CC);
+
if (EG(exception)) {
return ZEND_HASH_APPLY_STOP;
}
+
+ PHAR_STR(key, str_key);
+
if (key_type == HASH_KEY_IS_LONG) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator
%s returned an invalid key (must return a string)", ce->name);
return ZEND_HASH_APPLY_STOP;
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/shortarc.php?r1=1.12&r2=1.12.2.1&diff_format=u
Index: php-src/ext/phar/shortarc.php
diff -u php-src/ext/phar/shortarc.php:1.12
php-src/ext/phar/shortarc.php:1.12.2.1
--- php-src/ext/phar/shortarc.php:1.12 Wed Mar 12 03:55:11 2008
+++ php-src/ext/phar/shortarc.php Wed May 14 21:29:51 2008
@@ -268,7 +268,7 @@
$stat[7] . ")");
}
- if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) {
+ if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
die("Invalid internal .phar file (checksum error)");
}
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/stream.c?r1=1.27&r2=1.27.2.1&diff_format=u
Index: php-src/ext/phar/stream.c
diff -u php-src/ext/phar/stream.c:1.27 php-src/ext/phar/stream.c:1.27.2.1
--- php-src/ext/phar/stream.c:1.27 Wed May 7 05:38:29 2008
+++ php-src/ext/phar/stream.c Wed May 14 21:29:51 2008
@@ -501,7 +501,8 @@
php_stream_statbuf *ssb, php_stream_context
*context TSRMLS_DC) /* {{{ */
{
php_url *resource = NULL;
- char *internal_file, *key, *error;
+ phar_zstr key;
+ char *internal_file, *error, *str_key;
uint keylen;
ulong unused;
phar_archive_data *phar;
@@ -562,9 +563,10 @@
if (HASH_KEY_NON_EXISTANT !=
zend_hash_get_current_key_ex(
&phar->manifest, &key, &keylen,
&unused, 0, NULL)) {
- if (keylen >= (uint)internal_file_len && 0 ==
memcmp(internal_file, key, internal_file_len)) {
+ PHAR_STR(key, str_key);
+ if (keylen >= (uint)internal_file_len && 0 ==
memcmp(internal_file, str_key, internal_file_len)) {
/* directory found, all dirs have the
same stat */
- if (key[internal_file_len] == '/') {
+ if (str_key[internal_file_len] == '/') {
phar_dostat(phar, NULL, ssb, 1,
phar->alias, phar->alias_len TSRMLS_CC);
php_url_free(resource);
return SUCCESS;
@@ -577,7 +579,8 @@
}
/* check for mounted directories */
if (phar->mounted_dirs.arBuckets &&
zend_hash_num_elements(&phar->mounted_dirs)) {
- char *key;
+ phar_zstr key;
+ char *str_key;
ulong unused;
uint keylen;
@@ -586,7 +589,8 @@
if (HASH_KEY_NON_EXISTANT ==
zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0,
NULL)) {
break;
}
- if ((int)keylen >= internal_file_len ||
strncmp(key, internal_file, keylen)) {
+ PHAR_STR(key, str_key);
+ if ((int)keylen >= internal_file_len ||
strncmp(str_key, internal_file, keylen)) {
continue;
} else {
char *test;
@@ -594,7 +598,7 @@
phar_entry_info *entry;
php_stream_statbuf ssbi;
- if (SUCCESS !=
zend_hash_find(&phar->manifest, key, keylen, (void **) &entry)) {
+ if (SUCCESS !=
zend_hash_find(&phar->manifest, str_key, keylen, (void **) &entry)) {
goto free_resource;
}
if (!entry->tmp || !entry->is_mounted) {
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/stub.h?r1=1.13&r2=1.13.2.1&diff_format=u
Index: php-src/ext/phar/stub.h
diff -u php-src/ext/phar/stub.h:1.13 php-src/ext/phar/stub.h:1.13.2.1
--- php-src/ext/phar/stub.h:1.13 Wed Mar 12 03:55:11 2008
+++ php-src/ext/phar/stub.h Wed May 14 21:29:51 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: stub.h,v 1.13 2008/03/12 03:55:11 cellog Exp $ */
+/* $Id: stub.h,v 1.13.2.1 2008/05/14 21:29:51 sfox Exp $ */
static inline void phar_get_stub(const char *index_php, const char *web,
size_t *len, char **stub, const int name_len, const int web_len TSRMLS_DC)
{
@@ -25,9 +25,9 @@
static const char newstub1_1[] = "Extract_Phar::$temp))
{\nheader('HTTP/1.0 404 Not Found');\necho \"<html>\\n <head>\\n <title>File
Not Found<title>\\n </head>\\n <body>\\n <h1>404 - File \", $pt, \" Not
Found</h1>\\n </body>\\n</html>\";\nexit;\n}\n$b = pathinfo($a);\nif
(!isset($b['extension'])) {\nheader('Content-Type:
text/plain');\nheader('Content-Length: ' .
filesize($a));\nreadfile($a);\nexit;\n}\nif (isset($mimes[$b['extension']]))
{\nif ($mimes[$b['extension']] === 1) {\ninclude $a;\nexit;\n}\nif
($mimes[$b['extension']] === 2)
{\nhighlight_file($a);\nexit;\n}\nheader('Content-Type: '
.$mimes[$b['extension']]);\nheader('Content-Length: ' .
filesize($a));\nreadfile($a);\nexit;\n}\n}\n\nclass Extract_Phar\n{\nstatic
$temp;\nstatic $origdir;\nconst GZ = 0x1000;\nconst BZ2 = 0x2000;\nconst MASK =
0x3000;\nconst START = '";
static const char newstub2[] = "';\nconst LEN = ";
static const char newstub3_0[] = ";\n\nstatic function go($return =
false)\n{\n$fp = fopen(__FILE__, 'rb');\nfseek($fp, self::LEN);\n$L =
unpack('V', $a = fread($fp, 4));\n$m = '';\n\ndo {\n$read = 8192;\nif ($L[1] -
strlen($m) < 8192) {\n$read = $L[1] - strlen($m);\n}\n$last = fread($fp,
$read);\n$m .= $last;\n} while (strlen($last) && strlen($m) < $L[1]);\n\nif
(strlen($m) < $L[1]) {\ndie('ERROR: manifest length read was \"' .\nstrlen($m)
.'\" should be \"' .\n$L[1] . '\"');\n}\n\n$info = self::_unpack($m);\n$f =
$info['c'];\n\nif ($f & self::GZ) {\nif (!function_exists('gzinflate'))
{\ndie('Error: zlib extension is not enabled -' .\n' gzinflate() function
needed for zlib-compressed .phars');\n}\n}\n\nif ($f & self::BZ2) {\nif
(!function_exists('bzdecompress')) {\ndie('Error: bzip2 extension is not
enabled -' .\n' bzdecompress() function needed for bz2-compressed
.phars');\n}\n}\n\n$temp = self::tmpdir();\n\nif (!$temp ||
!is_writable($temp)) {\n$sessionpath = session_sa!
ve_path();\nif (strpos ($sessionpath, \";\") !== false)\n$sessionpath = substr
($sessionpath, strpos ($sessionpath, \";\")+1);\nif (!file_exists($sessionpath)
|| !is_dir($sessionpath)) {\ndie('Could not locate temporary directory to
extract phar');\n}\n$temp = $sessionpath;\n}\n\n$temp .=
'/pharextract/'.basename(__FILE__, '.phar');\nself::$temp =
$temp;\nself::$origdir = getcwd();[EMAIL PROTECTED]($temp, 0777, true);\n$temp
= realpath($temp);\n\nif (!file_exists($temp . DIRECTORY_SEPARATOR .
md5_file(__FILE__))) {\nself::_removeTmpFiles($temp, getcwd());[EMAIL
PROTECTED]($temp, 0777, true);[EMAIL PROTECTED]($temp . '/' .
md5_file(__FILE__), '');\n\nforeach ($info['m'] as $path => $file) {\n$a =
!file_exists(dirname($temp . '/' . $path));[EMAIL PROTECTED](dirname($temp .
'/' . $path), 0777, true);\nclearstatcache();\n\nif ($path[strlen($path) - 1]
== '/') [EMAIL PROTECTED]($temp . '/' . $path, 0777);\n} else
{\nfile_put_contents($temp . '/' . $path, self::extractFile($path, $file,
$fp));[EMAIL PROTECTED]($temp . '!
/' . $path, 0666);\n}\n}\n}\n\nchdir($temp);\n\nif (!$return) {\ninclu
de self::START;\n}\n}\n\nstatic fun";
- static const char newstub3_1[] = "ction tmpdir()\n{\nif (strpos(PHP_OS,
'WIN') !== false) {\nif ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP'))
{\nreturn $var;\n}\nif (is_dir('/temp') || mkdir('/temp')) {\nreturn
realpath('/temp');\n}\nreturn false;\n}\nif ($var = getenv('TMPDIR')) {\nreturn
$var;\n}\nreturn realpath('/tmp');\n}\n\nstatic function _unpack($m)\n{\n$info
= unpack('V', substr($m, 0, 4));\n $l = unpack('V', substr($m, 10, 4));\n$m =
substr($m, 14 + $l[1]);\n$s = unpack('V', substr($m, 0, 4));\n$o = 0;\n$start =
4 + $s[1];\n$ret['c'] = 0;\n\nfor ($i = 0; $i < $info[1]; $i++) {\n $len =
unpack('V', substr($m, $start, 4));\n$start += 4;\n $savepath = substr($m,
$start, $len[1]);\n$start += $len[1];\n $ret['m'][$savepath] =
array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start,
24)));\n$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]\n&
0xffffffff);\n$ret['m'][$savepath][7] = $o;\n$o +=
$ret['m'][$savepath][2];\n$start += 24 + $ret['m!
'][$savepath][5];\n$ret['c'] |= $ret['m'][$savepath][4] &
self::MASK;\n}\nreturn $ret;\n}\n\nstatic function extractFile($path, $entry,
$fp)\n{\n$data = '';\n$c = $entry[2];\n\nwhile ($c) {\nif ($c < 8192) {\n$data
.= @fread($fp, $c);\n$c = 0;\n} else {\n$c -= 8192;\n$data .= @fread($fp,
8192);\n}\n}\n\nif ($entry[4] & self::GZ) {\n$data = gzinflate($data);\n}
elseif ($entry[4] & self::BZ2) {\n$data = bzdecompress($data);\n}\n\nif
(strlen($data) != $entry[0]) {\ndie(\"Invalid internal .phar file (size error
\" . strlen($data) . \" != \" .\n$stat[7] . \")\");\n}\n\nif ($entry[3] !=
sprintf(\"%u\", crc32($data) & 0xffffffff)) {\ndie(\"Invalid internal .phar
file (checksum error)\");\n}\n\nreturn $data;\n}\n\nstatic function
_removeTmpFiles($temp, $origdir)\n{\nchdir($temp);\n\nforeach (glob('*') as $f)
{\nif (file_exists($f)) {\nis_dir($f) ? @rmdir($f) : @unlink($f);\nif
(file_exists($f) && is_dir($f)) {\nself::_removeTmpFiles($f, getcwd());[EMAIL
PROTECTED]($temp);\nclears!
tatcache();\nchdir($origdir);\n}\n}\n\nExtract_Phar::go();\n__HALT_COM
PILER(); ?>";
+ static const char newstub3_1[] = "ction tmpdir()\n{\nif (strpos(PHP_OS,
'WIN') !== false) {\nif ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP'))
{\nreturn $var;\n}\nif (is_dir('/temp') || mkdir('/temp')) {\nreturn
realpath('/temp');\n}\nreturn false;\n}\nif ($var = getenv('TMPDIR')) {\nreturn
$var;\n}\nreturn realpath('/tmp');\n}\n\nstatic function _unpack($m)\n{\n$info
= unpack('V', substr($m, 0, 4));\n $l = unpack('V', substr($m, 10, 4));\n$m =
substr($m, 14 + $l[1]);\n$s = unpack('V', substr($m, 0, 4));\n$o = 0;\n$start =
4 + $s[1];\n$ret['c'] = 0;\n\nfor ($i = 0; $i < $info[1]; $i++) {\n $len =
unpack('V', substr($m, $start, 4));\n$start += 4;\n $savepath = substr($m,
$start, $len[1]);\n$start += $len[1];\n $ret['m'][$savepath] =
array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start,
24)));\n$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]\n&
0xffffffff);\n$ret['m'][$savepath][7] = $o;\n$o +=
$ret['m'][$savepath][2];\n$start += 24 + $ret['m!
'][$savepath][5];\n$ret['c'] |= $ret['m'][$savepath][4] &
self::MASK;\n}\nreturn $ret;\n}\n\nstatic function extractFile($path, $entry,
$fp)\n{\n$data = '';\n$c = $entry[2];\n\nwhile ($c) {\nif ($c < 8192) {\n$data
.= @fread($fp, $c);\n$c = 0;\n} else {\n$c -= 8192;\n$data .= @fread($fp,
8192);\n}\n}\n\nif ($entry[4] & self::GZ) {\n$data = gzinflate($data);\n}
elseif ($entry[4] & self::BZ2) {\n$data = bzdecompress($data);\n}\n\nif
(strlen($data) != $entry[0]) {\ndie(\"Invalid internal .phar file (size error
\" . strlen($data) . \" != \" .\n$stat[7] . \")\");\n}\n\nif ($entry[3] !=
sprintf(\"%u\", crc32((binary)$data) & 0xffffffff)) {\ndie(\"Invalid internal
.phar file (checksum error)\");\n}\n\nreturn $data;\n}\n\nstatic function
_removeTmpFiles($temp, $origdir)\n{\nchdir($temp);\n\nforeach (glob('*') as $f)
{\nif (file_exists($f)) {\nis_dir($f) ? @rmdir($f) : @unlink($f);\nif
(file_exists($f) && is_dir($f)) {\nself::_removeTmpFiles($f, getcwd());[EMAIL
PROTECTED]($temp);!
\nclearstatcache();\nchdir($origdir);\n}\n}\n\nExtract_Phar::go();\n__
HALT_COMPILER(); ?>";
- static const int newstub_len = 6633;
+ static const int newstub_len = 6641;
*len = spprintf(stub, name_len + web_len + newstub_len,
"%s%s%s%s%s%s%d%s%s", newstub0, web, newstub1_0, newstub1_1, index_php,
newstub2, name_len + web_len + newstub_len, newstub3_0, newstub3_1);
}
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/util.c?r1=1.55&r2=1.55.2.1&diff_format=u
Index: php-src/ext/phar/util.c
diff -u php-src/ext/phar/util.c:1.55 php-src/ext/phar/util.c:1.55.2.1
--- php-src/ext/phar/util.c:1.55 Mon May 12 20:42:06 2008
+++ php-src/ext/phar/util.c Wed May 14 21:29:51 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: util.c,v 1.55 2008/05/12 20:42:06 cellog Exp $ */
+/* $Id: util.c,v 1.55.2.1 2008/05/14 21:29:51 sfox Exp $ */
#include "phar_internal.h"
#if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
@@ -1183,7 +1183,8 @@
}
return entry;
} else if (phar->mounted_dirs.arBuckets &&
zend_hash_num_elements(&phar->mounted_dirs)) {
- char *key;
+ phar_zstr key;
+ char *str_key;
ulong unused;
uint keylen;
@@ -1192,7 +1193,10 @@
if (HASH_KEY_NON_EXISTANT ==
zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0,
NULL)) {
break;
}
- if ((int)keylen >= path_len || strncmp(key, path,
keylen)) {
+
+ PHAR_STR(key, str_key);
+
+ if ((int)keylen >= path_len || strncmp(str_key, path,
keylen)) {
continue;
} else {
char *test;
@@ -1200,15 +1204,15 @@
phar_entry_info *entry;
php_stream_statbuf ssb;
- if (SUCCESS != zend_hash_find(&phar->manifest,
key, keylen, (void **) &entry)) {
+ if (SUCCESS != zend_hash_find(&phar->manifest,
str_key, keylen, (void **) &entry)) {
if (error) {
- spprintf(error, 4096, "phar
internal error: mounted path \"%s\" could not be retrieved from manifest", key);
+ spprintf(error, 4096, "phar
internal error: mounted path \"%s\" could not be retrieved from manifest",
str_key);
}
return NULL;
}
if (!entry->tmp || !entry->is_mounted) {
if (error) {
- spprintf(error, 4096, "phar
internal error: mounted path \"%s\" is not properly initialized as a mounted
path", key);
+ spprintf(error, 4096, "phar
internal error: mounted path \"%s\" is not properly initialized as a mounted
path", str_key);
}
return NULL;
}
@@ -1254,7 +1258,8 @@
if (dir) {
/* try to find a directory */
HashTable *manifest;
- char *key;
+ phar_zstr key;
+ char *str_key;
uint keylen;
ulong unused;
@@ -1267,14 +1272,17 @@
if (HASH_KEY_NON_EXISTANT ==
zend_hash_get_current_key_ex(manifest, &key, &keylen, &unused, 0, NULL)) {
break;
}
- if (0 != memcmp(key, path, path_len)) {
+
+ PHAR_STR(key, str_key);
+
+ if (0 != memcmp(str_key, path, path_len)) {
/* entry in directory not found */
if (SUCCESS !=
zend_hash_move_forward(manifest)) {
break;
}
continue;
} else {
- if (key[path_len] != '/') {
+ if (str_key[path_len] != '/') {
if (SUCCESS !=
zend_hash_move_forward(manifest)) {
break;
}
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/files/phar_test.inc?r1=1.2&r2=1.2.2.1&diff_format=u
Index: php-src/ext/phar/tests/files/phar_test.inc
diff -u php-src/ext/phar/tests/files/phar_test.inc:1.2
php-src/ext/phar/tests/files/phar_test.inc:1.2.2.1
--- php-src/ext/phar/tests/files/phar_test.inc:1.2 Tue May 6 21:14:52 2008
+++ php-src/ext/phar/tests/files/phar_test.inc Wed May 14 21:29:51 2008
@@ -36,7 +36,7 @@
if (empty($comp)) $comp = $cont;
if (empty($ulen)) $ulen = strlen($cont);
if (empty($clen)) $clen = strlen($comp);
- if (empty($crc32))$crc32= crc32($cont);
+ if (empty($crc32))$crc32= crc32((binary)$cont);
if (isset($meta)) $meta = serialize($meta);
// write manifest entry
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/phar_commitwrite.phpt?r1=1.17&r2=1.17.2.1&diff_format=u
Index: php-src/ext/phar/tests/phar_commitwrite.phpt
diff -u php-src/ext/phar/tests/phar_commitwrite.phpt:1.17
php-src/ext/phar/tests/phar_commitwrite.phpt:1.17.2.1
--- php-src/ext/phar/tests/phar_commitwrite.phpt:1.17 Wed Mar 12 03:55:11 2008
+++ php-src/ext/phar/tests/phar_commitwrite.phpt Wed May 14 21:29:51 2008
@@ -29,7 +29,7 @@
__HALT_COMPILER();
?>
--EXPECT--
-int(6651)
+int(6659)
string(200) "<?php
function __autoload($class)
{
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/phar_convert_repeated.phpt?r1=1.6&r2=1.6.2.1&diff_format=u
Index: php-src/ext/phar/tests/phar_convert_repeated.phpt
diff -u php-src/ext/phar/tests/phar_convert_repeated.phpt:1.6
php-src/ext/phar/tests/phar_convert_repeated.phpt:1.6.2.1
--- php-src/ext/phar/tests/phar_convert_repeated.phpt:1.6 Fri May 2
05:05:54 2008
+++ php-src/ext/phar/tests/phar_convert_repeated.phpt Wed May 14 21:29:51 2008
@@ -123,7 +123,7 @@
bool(true)
bool(false)
bool(false)
-int(6651)
+int(6659)
NULL
================= convertToZip() =====================
bool(false)
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/phar_create_in_cwd.phpt?r1=1.15&r2=1.15.2.1&diff_format=u
Index: php-src/ext/phar/tests/phar_create_in_cwd.phpt
diff -u php-src/ext/phar/tests/phar_create_in_cwd.phpt:1.15
php-src/ext/phar/tests/phar_create_in_cwd.phpt:1.15.2.1
--- php-src/ext/phar/tests/phar_create_in_cwd.phpt:1.15 Wed Mar 12 03:55:11 2008
+++ php-src/ext/phar/tests/phar_create_in_cwd.phpt Wed May 14 21:29:51 2008
@@ -32,7 +32,7 @@
unlink(dirname(__FILE__) . '/brandnewphar.phar');
?>
--EXPECT--
-int(6651)
+int(6659)
string(200) "<?php
function __autoload($class)
{
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/phar_createdefaultstub.phpt?r1=1.8&r2=1.8.2.1&diff_format=u
Index: php-src/ext/phar/tests/phar_createdefaultstub.phpt
diff -u php-src/ext/phar/tests/phar_createdefaultstub.phpt:1.8
php-src/ext/phar/tests/phar_createdefaultstub.phpt:1.8.2.1
--- php-src/ext/phar/tests/phar_createdefaultstub.phpt:1.8 Wed Mar 12
03:55:11 2008
+++ php-src/ext/phar/tests/phar_createdefaultstub.phpt Wed May 14 21:29:51 2008
@@ -34,7 +34,7 @@
?>
===DONE===
--EXPECT--
-string(6651) "<?php
+string(6659) "<?php
$web = 'index.php';
@@ -144,7 +144,7 @@
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'index.php';
-const LEN = 6653;
+const LEN = 6661;
static function go($return = false)
{
@@ -298,7 +298,7 @@
$stat[7] . ")");
}
-if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) {
+if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
die("Invalid internal .phar file (checksum error)");
}
@@ -328,7 +328,7 @@
__HALT_COMPILER(); ?>"
============================================================================
============================================================================
-string(6662) "<?php
+string(6670) "<?php
$web = 'index.php';
@@ -438,7 +438,7 @@
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'my/custom/thingy.php';
-const LEN = 6664;
+const LEN = 6672;
static function go($return = false)
{
@@ -592,7 +592,7 @@
$stat[7] . ")");
}
-if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) {
+if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
die("Invalid internal .phar file (checksum error)");
}
@@ -622,7 +622,7 @@
__HALT_COMPILER(); ?>"
============================================================================
============================================================================
-int(7042)
+int(7050)
============================================================================
============================================================================
Illegal filename passed in for stub creation, was 401 characters long, and
only 400 or less is allowed
@@ -630,7 +630,7 @@
============================================================================
============================================================================
============================================================================
-string(6664) "<?php
+string(6672) "<?php
$web = 'the/web.php';
@@ -740,7 +740,7 @@
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'my/custom/thingy.php';
-const LEN = 6666;
+const LEN = 6674;
static function go($return = false)
{
@@ -894,7 +894,7 @@
$stat[7] . ")");
}
-if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) {
+if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
die("Invalid internal .phar file (checksum error)");
}
@@ -924,6 +924,6 @@
__HALT_COMPILER(); ?>"
============================================================================
============================================================================
-int(7042)
+int(7050)
Illegal web filename passed in for stub creation, was 401 characters long, and
only 400 or less is allowed
===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/phar_setdefaultstub.phpt?r1=1.4&r2=1.4.2.1&diff_format=u
Index: php-src/ext/phar/tests/phar_setdefaultstub.phpt
diff -u php-src/ext/phar/tests/phar_setdefaultstub.phpt:1.4
php-src/ext/phar/tests/phar_setdefaultstub.phpt:1.4.2.1
--- php-src/ext/phar/tests/phar_setdefaultstub.phpt:1.4 Wed Mar 12 03:55:11 2008
+++ php-src/ext/phar/tests/phar_setdefaultstub.phpt Wed May 14 21:29:51 2008
@@ -54,7 +54,7 @@
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
?>
--EXPECT--
-string(6653) "<?php
+string(6661) "<?php
$web = 'index.php';
@@ -164,7 +164,7 @@
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'index.php';
-const LEN = 6653;
+const LEN = 6661;
static function go($return = false)
{
@@ -318,7 +318,7 @@
$stat[7] . ")");
}
-if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) {
+if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
die("Invalid internal .phar file (checksum error)");
}
@@ -349,7 +349,7 @@
"
============================================================================
============================================================================
-string(6664) "<?php
+string(6672) "<?php
$web = 'index.php';
@@ -459,7 +459,7 @@
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'my/custom/thingy.php';
-const LEN = 6664;
+const LEN = 6672;
static function go($return = false)
{
@@ -613,7 +613,7 @@
$stat[7] . ")");
}
-if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) {
+if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
die("Invalid internal .phar file (checksum error)");
}
@@ -644,7 +644,7 @@
"
============================================================================
============================================================================
-string(6666) "<?php
+string(6674) "<?php
$web = 'the/web.php';
@@ -754,7 +754,7 @@
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'my/custom/thingy.php';
-const LEN = 6666;
+const LEN = 6674;
static function go($return = false)
{
@@ -908,7 +908,7 @@
$stat[7] . ")");
}
-if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) {
+if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
die("Invalid internal .phar file (checksum error)");
}
@@ -939,6 +939,6 @@
"
============================================================================
============================================================================
-int(7044)
+int(7052)
Illegal filename passed in for stub creation, was 401 characters long, and
only 400 or less is allowed
===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/tar/phar_convert_phar.phpt?r1=1.9&r2=1.9.2.1&diff_format=u
Index: php-src/ext/phar/tests/tar/phar_convert_phar.phpt
diff -u php-src/ext/phar/tests/tar/phar_convert_phar.phpt:1.9
php-src/ext/phar/tests/tar/phar_convert_phar.phpt:1.9.2.1
--- php-src/ext/phar/tests/tar/phar_convert_phar.phpt:1.9 Fri May 2
05:05:54 2008
+++ php-src/ext/phar/tests/tar/phar_convert_phar.phpt Wed May 14 21:29:51 2008
@@ -47,12 +47,12 @@
?>
--EXPECT--
bool(false)
-int(6651)
+int(6659)
bool(true)
string(60) "<?php // tar-based phar archive stub file
__HALT_COMPILER();"
bool(true)
-int(6651)
+int(6659)
bool(true)
-int(6651)
+int(6659)
===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/tar/phar_convert_phar2.phpt?r1=1.11&r2=1.11.2.1&diff_format=u
Index: php-src/ext/phar/tests/tar/phar_convert_phar2.phpt
diff -u php-src/ext/phar/tests/tar/phar_convert_phar2.phpt:1.11
php-src/ext/phar/tests/tar/phar_convert_phar2.phpt:1.11.2.1
--- php-src/ext/phar/tests/tar/phar_convert_phar2.phpt:1.11 Fri May 2
05:05:54 2008
+++ php-src/ext/phar/tests/tar/phar_convert_phar2.phpt Wed May 14 21:29:51 2008
@@ -49,14 +49,14 @@
?>
--EXPECT--
bool(false)
-int(6651)
+int(6659)
bool(true)
string(60) "<?php // tar-based phar archive stub file
__HALT_COMPILER();"
bool(true)
int(4096)
-int(6651)
+int(6659)
bool(true)
bool(true)
-int(6651)
+int(6659)
===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/zip/phar_convert_phar.phpt?r1=1.12&r2=1.12.2.1&diff_format=u
Index: php-src/ext/phar/tests/zip/phar_convert_phar.phpt
diff -u php-src/ext/phar/tests/zip/phar_convert_phar.phpt:1.12
php-src/ext/phar/tests/zip/phar_convert_phar.phpt:1.12.2.1
--- php-src/ext/phar/tests/zip/phar_convert_phar.phpt:1.12 Fri May 2
05:05:54 2008
+++ php-src/ext/phar/tests/zip/phar_convert_phar.phpt Wed May 14 21:29:51 2008
@@ -46,12 +46,12 @@
?>
--EXPECT--
bool(false)
-int(6651)
+int(6659)
bool(true)
string(60) "<?php // zip-based phar archive stub file
__HALT_COMPILER();"
bool(true)
-int(6651)
+int(6659)
bool(true)
-int(6651)
+int(6659)
===DONE===
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php