- Make internal code forward-compatible. This included a binary cast in the default stub, hence test updates.
This commit is contained in:
Steph Fox 2008-05-14 21:29:51 +00:00
parent b3b5126954
commit 6a0682d986
18 changed files with 129 additions and 85 deletions

View file

@ -94,7 +94,8 @@ static size_t phar_dir_read(php_stream *stream, char *buf, size_t count TSRMLS_D
{ {
size_t to_read; size_t to_read;
HashTable *data = (HashTable *)stream->abstract; HashTable *data = (HashTable *)stream->abstract;
char *key; phar_zstr key;
char *str_key;
uint keylen; uint keylen;
ulong unused; ulong unused;
@ -104,13 +105,14 @@ static size_t phar_dir_read(php_stream *stream, char *buf, size_t count TSRMLS_D
if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(data, &key, &keylen, &unused, 0, NULL)) { if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(data, &key, &keylen, &unused, 0, NULL)) {
return 0; return 0;
} }
PHAR_STR(key, str_key);
zend_hash_move_forward(data); zend_hash_move_forward(data);
to_read = MIN(keylen, count); to_read = MIN(keylen, count);
if (to_read == 0 || count < keylen) { if (to_read == 0 || count < keylen) {
return 0; return 0;
} }
memset(buf, 0, sizeof(php_stream_dirent)); 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'; ((php_stream_dirent *) buf)->d_name[to_read + 1] = '\0';
return sizeof(php_stream_dirent); return sizeof(php_stream_dirent);
@ -186,10 +188,11 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
{ {
HashTable *data; HashTable *data;
int dirlen = strlen(dir); int dirlen = strlen(dir);
char *save, *found, *key; phar_zstr key;
char *entry, *found, *save, *str_key;
uint keylen; uint keylen;
ulong unused; ulong unused;
char *entry;
ALLOC_HASHTABLE(data); ALLOC_HASHTABLE(data);
zend_hash_init(data, 64, zend_get_hash_value, NULL, 0); zend_hash_init(data, 64, zend_get_hash_value, NULL, 0);
@ -203,8 +206,9 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(manifest, &key, &keylen, &unused, 0, NULL)) { if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(manifest, &key, &keylen, &unused, 0, NULL)) {
break; break;
} }
PHAR_STR(key, str_key);
if (keylen <= (uint)dirlen) { 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)) { if (SUCCESS != zend_hash_move_forward(manifest)) {
break; break;
} }
@ -213,27 +217,27 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
} }
if (*dir == '/') { if (*dir == '/') {
/* root directory */ /* 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 */ /* the entry has a path separator and is a subdirectory */
entry = (char *) safe_emalloc(found - key, 1, 1); entry = (char *) safe_emalloc(found - str_key, 1, 1);
memcpy(entry, key, found - key); memcpy(entry, str_key, found - str_key);
keylen = found - key; keylen = found - str_key;
entry[keylen] = '\0'; entry[keylen] = '\0';
} else { } else {
entry = (char *) safe_emalloc(keylen, 1, 1); entry = (char *) safe_emalloc(keylen, 1, 1);
memcpy(entry, key, keylen); memcpy(entry, str_key, keylen);
entry[keylen] = '\0'; entry[keylen] = '\0';
} }
goto PHAR_ADD_ENTRY; goto PHAR_ADD_ENTRY;
} else { } else {
if (0 != memcmp(key, dir, dirlen)) { if (0 != memcmp(str_key, dir, dirlen)) {
/* entry in directory not found */ /* entry in directory not found */
if (SUCCESS != zend_hash_move_forward(manifest)) { if (SUCCESS != zend_hash_move_forward(manifest)) {
break; break;
} }
continue; continue;
} else { } else {
if (key[dirlen] != '/') { if (str_key[dirlen] != '/') {
if (SUCCESS != zend_hash_move_forward(manifest)) { if (SUCCESS != zend_hash_move_forward(manifest)) {
break; break;
} }
@ -241,7 +245,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
} }
} }
} }
save = key; save = str_key;
save += dirlen + 1; /* seek to just past the path separator */ save += dirlen + 1; /* seek to just past the path separator */
if (NULL != (found = (char *) memchr(save, '/', keylen - dirlen - 1))) { if (NULL != (found = (char *) memchr(save, '/', keylen - dirlen - 1))) {
/* is subdirectory */ /* is subdirectory */
@ -289,7 +293,8 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char
{ {
php_url *resource = NULL; php_url *resource = NULL;
php_stream *ret; php_stream *ret;
char *internal_file, *key, *error; char *internal_file, *error, *str_key;
phar_zstr key;
uint keylen; uint keylen;
ulong unused; ulong unused;
phar_archive_data *phar; phar_archive_data *phar;
@ -367,7 +372,8 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char
if (HASH_KEY_NON_EXISTANT != if (HASH_KEY_NON_EXISTANT !=
zend_hash_get_current_key_ex( zend_hash_get_current_key_ex(
&phar->manifest, &key, &keylen, &unused, 0, NULL)) { &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 */ /* directory found */
internal_file = estrndup(internal_file, internal_file = estrndup(internal_file,
i_len); i_len);

View file

@ -655,7 +655,8 @@ notfound:
goto stat_entry; goto stat_entry;
} else { } else {
phar_archive_data *phar = *pphar; phar_archive_data *phar = *pphar;
char *key; phar_zstr key;
char *str_key;
uint keylen; uint keylen;
ulong unused; ulong unused;
@ -667,11 +668,12 @@ notfound:
if (HASH_KEY_NON_EXISTANT != if (HASH_KEY_NON_EXISTANT !=
zend_hash_get_current_key_ex( zend_hash_get_current_key_ex(
&phar->manifest, &key, &keylen, &unused, 0, NULL)) { &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(save2);
efree(entry); efree(entry);
/* directory found, all dirs have the same stat */ /* directory found, all dirs have the same stat */
if (key[actual_len] == '/') { if (str_key[actual_len] == '/') {
sb.st_size = 0; sb.st_size = 0;
sb.st_mode = 0777; sb.st_mode = 0777;
sb.st_mode |= S_IFDIR; /* regular directory */ sb.st_mode |= S_IFDIR; /* regular directory */

View file

@ -1592,7 +1592,8 @@ woohoo:
return FAILURE; return FAILURE;
} }
} else { } else {
char *key; phar_zstr key;
char *str_key;
uint keylen; uint keylen;
ulong unused; ulong unused;
@ -1602,11 +1603,13 @@ woohoo:
break; break;
} }
PHAR_STR(key, str_key);
if (keylen > (uint) filename_len) { if (keylen > (uint) filename_len) {
zend_hash_move_forward(&(PHAR_GLOBALS->phar_fname_map)); zend_hash_move_forward(&(PHAR_GLOBALS->phar_fname_map));
continue; 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')) { || filename[keylen] == '/' || filename[keylen] == '\0')) {
if (FAILURE == zend_hash_get_current_data(&(PHAR_GLOBALS->phar_fname_map), (void **) &pphar)) { if (FAILURE == zend_hash_get_current_data(&(PHAR_GLOBALS->phar_fname_map), (void **) &pphar)) {
break; break;
@ -2847,7 +2850,7 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type
} }
} else if (phar->flags & PHAR_FILE_COMPRESSION_MASK) { } else if (phar->flags & PHAR_FILE_COMPRESSION_MASK) {
/* compressed phar */ /* compressed phar */
#if PHP_VERSION_ID >= 50300 && PHP_VERSION_ID < 60000 #if PHP_VERSION_ID >= 50300
file_handle->type = ZEND_HANDLE_STREAM; file_handle->type = ZEND_HANDLE_STREAM;
file_handle->free_filename = 0; file_handle->free_filename = 0;
file_handle->handle.stream.handle = phar; file_handle->handle.stream.handle = phar;

View file

@ -354,8 +354,17 @@ extern char *(*phar_save_resolve_path)(const char *filename, int filename_len TS
# endif # endif
#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 #ifdef PHP_WIN32
char *tsrm_strtok_r(char *s, const char *delim, char **last); char *tsrm_strtok_r(char *s, const char *delim, char **last);

View file

@ -778,7 +778,7 @@ PHP_METHOD(Phar, webPhar)
mime.len = Z_STRLEN_PP(val); \ mime.len = Z_STRLEN_PP(val); \
} \ } \
mime.type = ret; \ 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 (mimeoverride) {
if (!zend_hash_num_elements(Z_ARRVAL_P(mimeoverride))) { if (!zend_hash_num_elements(Z_ARRVAL_P(mimeoverride))) {
@ -786,9 +786,11 @@ PHP_METHOD(Phar, webPhar)
} }
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))) { 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; zval **val;
char *key; phar_zstr key;
char *str_key;
uint keylen; uint keylen;
ulong intkey; ulong intkey;
if (HASH_KEY_IS_LONG == zend_hash_get_current_key_ex(Z_ARRVAL_P(mimeoverride), &key, &keylen, &intkey, 0, NULL)) { 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); 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); phar_entry_delref(phar TSRMLS_CC);
@ -797,8 +799,11 @@ PHP_METHOD(Phar, webPhar)
#endif #endif
RETURN_FALSE; RETURN_FALSE;
} }
PHAR_STR(key, str_key);
if (FAILURE == zend_hash_get_current_data(Z_ARRVAL_P(mimeoverride), (void **) &val)) { 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); phar_entry_delref(phar TSRMLS_CC);
#ifdef PHP_WIN32 #ifdef PHP_WIN32
efree(fname); efree(fname);
@ -1114,11 +1119,8 @@ PHP_METHOD(Phar, __construct)
return; return;
} }
#if PHP_VERSION_ID >= 60000 PHAR_STR(phar_obj->std.ce->name, objname);
objname = phar_obj->std.ce->name.s;
#else
objname = phar_obj->std.ce->name;
#endif
if (!strncmp(objname, "PharData", 8)) { if (!strncmp(objname, "PharData", 8)) {
is_data = 1; is_data = 1;
} else { } else {
@ -1315,7 +1317,9 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
phar_entry_data *data; phar_entry_data *data;
php_stream *fp; php_stream *fp;
long contents_len; 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; zend_class_entry *ce = p_obj->c;
phar_archive_object *phar_obj = p_obj->p; phar_archive_object *phar_obj = p_obj->p;
char *str = "[stream]"; char *str = "[stream]";
@ -1339,10 +1343,14 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
return ZEND_HASH_APPLY_STOP; return ZEND_HASH_APPLY_STOP;
} }
if (iter->funcs->get_current_key) { 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)) { if (EG(exception)) {
return ZEND_HASH_APPLY_STOP; return ZEND_HASH_APPLY_STOP;
} }
PHAR_STR(key, str_key);
if (key_type == HASH_KEY_IS_LONG) { 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); 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; return ZEND_HASH_APPLY_STOP;
@ -1438,10 +1446,14 @@ phar_spl_fileinfo:
} }
} else { } else {
if (iter->funcs->get_current_key) { 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)) { if (EG(exception)) {
return ZEND_HASH_APPLY_STOP; return ZEND_HASH_APPLY_STOP;
} }
PHAR_STR(key, str_key);
if (key_type == HASH_KEY_IS_LONG) { 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); 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; return ZEND_HASH_APPLY_STOP;

View file

@ -268,7 +268,7 @@ class Extract_Phar
$stat[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)"); die("Invalid internal .phar file (checksum error)");
} }

View file

@ -501,7 +501,8 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags,
php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC) /* {{{ */ php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC) /* {{{ */
{ {
php_url *resource = NULL; php_url *resource = NULL;
char *internal_file, *key, *error; phar_zstr key;
char *internal_file, *error, *str_key;
uint keylen; uint keylen;
ulong unused; ulong unused;
phar_archive_data *phar; phar_archive_data *phar;
@ -562,9 +563,10 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags,
if (HASH_KEY_NON_EXISTANT != if (HASH_KEY_NON_EXISTANT !=
zend_hash_get_current_key_ex( zend_hash_get_current_key_ex(
&phar->manifest, &key, &keylen, &unused, 0, NULL)) { &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 */ /* 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); phar_dostat(phar, NULL, ssb, 1, phar->alias, phar->alias_len TSRMLS_CC);
php_url_free(resource); php_url_free(resource);
return SUCCESS; return SUCCESS;
@ -577,7 +579,8 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags,
} }
/* check for mounted directories */ /* check for mounted directories */
if (phar->mounted_dirs.arBuckets && zend_hash_num_elements(&phar->mounted_dirs)) { if (phar->mounted_dirs.arBuckets && zend_hash_num_elements(&phar->mounted_dirs)) {
char *key; phar_zstr key;
char *str_key;
ulong unused; ulong unused;
uint keylen; uint keylen;
@ -586,7 +589,8 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags,
if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0, NULL)) { if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0, NULL)) {
break; 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; continue;
} else { } else {
char *test; char *test;
@ -594,7 +598,7 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags,
phar_entry_info *entry; phar_entry_info *entry;
php_stream_statbuf ssbi; 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; goto free_resource;
} }
if (!entry->tmp || !entry->is_mounted) { if (!entry->tmp || !entry->is_mounted) {

View file

@ -25,9 +25,9 @@ static inline void phar_get_stub(const char *index_php, const char *web, size_t
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 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 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_save_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();\n@mkdir($temp, 0777, true);\n$temp = realpath($temp);\n\nif (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {\nself::_removeTmpFiles($temp, getcwd());\n@mkdir($temp, 0777, true);\n@file_put_contents($temp . '/' . md5_file(__FILE__), '');\n\nforeach ($info['m'] as $path => $file) {\n$a = !file_exists(dirname($temp . '/' . $path));\n@mkdir(dirname($temp . '/' . $path), 0777, true);\nclearstatcache();\n\nif ($path[strlen($path) - 1] == '/') {\n@mkdir($temp . '/' . $path, 0777);\n} else {\nfile_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));\n@chmod($temp . '/' . $path, 0666);\n}\n}\n}\n\nchdir($temp);\n\nif (!$return) {\ninclude self::START;\n}\n}\n\nstatic fun"; 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_save_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();\n@mkdir($temp, 0777, true);\n$temp = realpath($temp);\n\nif (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {\nself::_removeTmpFiles($temp, getcwd());\n@mkdir($temp, 0777, true);\n@file_put_contents($temp . '/' . md5_file(__FILE__), '');\n\nforeach ($info['m'] as $path => $file) {\n$a = !file_exists(dirname($temp . '/' . $path));\n@mkdir(dirname($temp . '/' . $path), 0777, true);\nclearstatcache();\n\nif ($path[strlen($path) - 1] == '/') {\n@mkdir($temp . '/' . $path, 0777);\n} else {\nfile_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));\n@chmod($temp . '/' . $path, 0666);\n}\n}\n}\n\nchdir($temp);\n\nif (!$return) {\ninclude 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());\n}\n}\n}\n\n@rmdir($temp);\nclearstatcache();\nchdir($origdir);\n}\n}\n\nExtract_Phar::go();\n__HALT_COMPILER(); ?>"; 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());\n}\n}\n}\n\n@rmdir($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); *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);
} }

View file

@ -36,7 +36,7 @@ foreach($files as $name => $cont)
if (empty($comp)) $comp = $cont; if (empty($comp)) $comp = $cont;
if (empty($ulen)) $ulen = strlen($cont); if (empty($ulen)) $ulen = strlen($cont);
if (empty($clen)) $clen = strlen($comp); 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); if (isset($meta)) $meta = serialize($meta);
// write manifest entry // write manifest entry

View file

@ -29,7 +29,7 @@ unlink(dirname(__FILE__) . '/brandnewphar.phar');
__HALT_COMPILER(); __HALT_COMPILER();
?> ?>
--EXPECT-- --EXPECT--
int(6651) int(6659)
string(200) "<?php string(200) "<?php
function __autoload($class) function __autoload($class)
{ {

View file

@ -123,7 +123,7 @@ NULL
bool(true) bool(true)
bool(false) bool(false)
bool(false) bool(false)
int(6651) int(6659)
NULL NULL
================= convertToZip() ===================== ================= convertToZip() =====================
bool(false) bool(false)

View file

@ -32,7 +32,7 @@ __HALT_COMPILER();
unlink(dirname(__FILE__) . '/brandnewphar.phar'); unlink(dirname(__FILE__) . '/brandnewphar.phar');
?> ?>
--EXPECT-- --EXPECT--
int(6651) int(6659)
string(200) "<?php string(200) "<?php
function __autoload($class) function __autoload($class)
{ {

View file

@ -34,7 +34,7 @@ echo $e->getMessage() . "\n";
?> ?>
===DONE=== ===DONE===
--EXPECT-- --EXPECT--
string(6651) "<?php string(6659) "<?php
$web = 'index.php'; $web = 'index.php';
@ -144,7 +144,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000; const BZ2 = 0x2000;
const MASK = 0x3000; const MASK = 0x3000;
const START = 'index.php'; const START = 'index.php';
const LEN = 6653; const LEN = 6661;
static function go($return = false) static function go($return = false)
{ {
@ -298,7 +298,7 @@ die("Invalid internal .phar file (size error " . strlen($data) . " != " .
$stat[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)"); die("Invalid internal .phar file (checksum error)");
} }
@ -328,7 +328,7 @@ Extract_Phar::go();
__HALT_COMPILER(); ?>" __HALT_COMPILER(); ?>"
============================================================================ ============================================================================
============================================================================ ============================================================================
string(6662) "<?php string(6670) "<?php
$web = 'index.php'; $web = 'index.php';
@ -438,7 +438,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000; const BZ2 = 0x2000;
const MASK = 0x3000; const MASK = 0x3000;
const START = 'my/custom/thingy.php'; const START = 'my/custom/thingy.php';
const LEN = 6664; const LEN = 6672;
static function go($return = false) static function go($return = false)
{ {
@ -592,7 +592,7 @@ die("Invalid internal .phar file (size error " . strlen($data) . " != " .
$stat[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)"); die("Invalid internal .phar file (checksum error)");
} }
@ -622,7 +622,7 @@ Extract_Phar::go();
__HALT_COMPILER(); ?>" __HALT_COMPILER(); ?>"
============================================================================ ============================================================================
============================================================================ ============================================================================
int(7042) int(7050)
============================================================================ ============================================================================
============================================================================ ============================================================================
Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
@ -630,7 +630,7 @@ Illegal filename passed in for stub creation, was 401 characters long, and only
============================================================================ ============================================================================
============================================================================ ============================================================================
============================================================================ ============================================================================
string(6664) "<?php string(6672) "<?php
$web = 'the/web.php'; $web = 'the/web.php';
@ -740,7 +740,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000; const BZ2 = 0x2000;
const MASK = 0x3000; const MASK = 0x3000;
const START = 'my/custom/thingy.php'; const START = 'my/custom/thingy.php';
const LEN = 6666; const LEN = 6674;
static function go($return = false) static function go($return = false)
{ {
@ -894,7 +894,7 @@ die("Invalid internal .phar file (size error " . strlen($data) . " != " .
$stat[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)"); die("Invalid internal .phar file (checksum error)");
} }
@ -924,6 +924,6 @@ Extract_Phar::go();
__HALT_COMPILER(); ?>" __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 Illegal web filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
===DONE=== ===DONE===

View file

@ -54,7 +54,7 @@ try {
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
?> ?>
--EXPECT-- --EXPECT--
string(6653) "<?php string(6661) "<?php
$web = 'index.php'; $web = 'index.php';
@ -164,7 +164,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000; const BZ2 = 0x2000;
const MASK = 0x3000; const MASK = 0x3000;
const START = 'index.php'; const START = 'index.php';
const LEN = 6653; const LEN = 6661;
static function go($return = false) static function go($return = false)
{ {
@ -318,7 +318,7 @@ die("Invalid internal .phar file (size error " . strlen($data) . " != " .
$stat[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)"); die("Invalid internal .phar file (checksum error)");
} }
@ -349,7 +349,7 @@ __HALT_COMPILER(); ?>
" "
============================================================================ ============================================================================
============================================================================ ============================================================================
string(6664) "<?php string(6672) "<?php
$web = 'index.php'; $web = 'index.php';
@ -459,7 +459,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000; const BZ2 = 0x2000;
const MASK = 0x3000; const MASK = 0x3000;
const START = 'my/custom/thingy.php'; const START = 'my/custom/thingy.php';
const LEN = 6664; const LEN = 6672;
static function go($return = false) static function go($return = false)
{ {
@ -613,7 +613,7 @@ die("Invalid internal .phar file (size error " . strlen($data) . " != " .
$stat[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)"); die("Invalid internal .phar file (checksum error)");
} }
@ -644,7 +644,7 @@ __HALT_COMPILER(); ?>
" "
============================================================================ ============================================================================
============================================================================ ============================================================================
string(6666) "<?php string(6674) "<?php
$web = 'the/web.php'; $web = 'the/web.php';
@ -754,7 +754,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000; const BZ2 = 0x2000;
const MASK = 0x3000; const MASK = 0x3000;
const START = 'my/custom/thingy.php'; const START = 'my/custom/thingy.php';
const LEN = 6666; const LEN = 6674;
static function go($return = false) static function go($return = false)
{ {
@ -908,7 +908,7 @@ die("Invalid internal .phar file (size error " . strlen($data) . " != " .
$stat[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)"); die("Invalid internal .phar file (checksum error)");
} }
@ -939,6 +939,6 @@ __HALT_COMPILER(); ?>
" "
============================================================================ ============================================================================
============================================================================ ============================================================================
int(7044) int(7052)
Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
===DONE=== ===DONE===

View file

@ -47,12 +47,12 @@ __HALT_COMPILER();
?> ?>
--EXPECT-- --EXPECT--
bool(false) bool(false)
int(6651) int(6659)
bool(true) bool(true)
string(60) "<?php // tar-based phar archive stub file string(60) "<?php // tar-based phar archive stub file
__HALT_COMPILER();" __HALT_COMPILER();"
bool(true) bool(true)
int(6651) int(6659)
bool(true) bool(true)
int(6651) int(6659)
===DONE=== ===DONE===

View file

@ -49,14 +49,14 @@ __HALT_COMPILER();
?> ?>
--EXPECT-- --EXPECT--
bool(false) bool(false)
int(6651) int(6659)
bool(true) bool(true)
string(60) "<?php // tar-based phar archive stub file string(60) "<?php // tar-based phar archive stub file
__HALT_COMPILER();" __HALT_COMPILER();"
bool(true) bool(true)
int(4096) int(4096)
int(6651) int(6659)
bool(true) bool(true)
bool(true) bool(true)
int(6651) int(6659)
===DONE=== ===DONE===

View file

@ -46,12 +46,12 @@ __HALT_COMPILER();
?> ?>
--EXPECT-- --EXPECT--
bool(false) bool(false)
int(6651) int(6659)
bool(true) bool(true)
string(60) "<?php // zip-based phar archive stub file string(60) "<?php // zip-based phar archive stub file
__HALT_COMPILER();" __HALT_COMPILER();"
bool(true) bool(true)
int(6651) int(6659)
bool(true) bool(true)
int(6651) int(6659)
===DONE=== ===DONE===

View file

@ -1183,7 +1183,8 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
} }
return entry; return entry;
} else if (phar->mounted_dirs.arBuckets && zend_hash_num_elements(&phar->mounted_dirs)) { } else if (phar->mounted_dirs.arBuckets && zend_hash_num_elements(&phar->mounted_dirs)) {
char *key; phar_zstr key;
char *str_key;
ulong unused; ulong unused;
uint keylen; uint keylen;
@ -1192,7 +1193,10 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0, NULL)) { if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0, NULL)) {
break; 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; continue;
} else { } else {
char *test; char *test;
@ -1200,15 +1204,15 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
phar_entry_info *entry; phar_entry_info *entry;
php_stream_statbuf ssb; 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) { 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; return NULL;
} }
if (!entry->tmp || !entry->is_mounted) { if (!entry->tmp || !entry->is_mounted) {
if (error) { 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; return NULL;
} }
@ -1254,7 +1258,8 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
if (dir) { if (dir) {
/* try to find a directory */ /* try to find a directory */
HashTable *manifest; HashTable *manifest;
char *key; phar_zstr key;
char *str_key;
uint keylen; uint keylen;
ulong unused; ulong unused;
@ -1267,14 +1272,17 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(manifest, &key, &keylen, &unused, 0, NULL)) { if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(manifest, &key, &keylen, &unused, 0, NULL)) {
break; 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 */ /* entry in directory not found */
if (SUCCESS != zend_hash_move_forward(manifest)) { if (SUCCESS != zend_hash_move_forward(manifest)) {
break; break;
} }
continue; continue;
} else { } else {
if (key[path_len] != '/') { if (str_key[path_len] != '/') {
if (SUCCESS != zend_hash_move_forward(manifest)) { if (SUCCESS != zend_hash_move_forward(manifest)) {
break; break;
} }