mirror of
https://github.com/php/php-src.git
synced 2024-09-23 02:47:26 +00:00
- 'It builds on my box'.
- Don't expect any tests to pass.
This commit is contained in:
parent
461006fa97
commit
247d91e780
@ -94,7 +94,7 @@ static size_t phar_dir_read(php_stream *stream, char *buf, size_t count TSRMLS_D
|
||||
{
|
||||
size_t to_read;
|
||||
HashTable *data = (HashTable *)stream->abstract;
|
||||
char *key;
|
||||
zstr key;
|
||||
uint keylen;
|
||||
ulong unused;
|
||||
|
||||
@ -110,7 +110,7 @@ static size_t phar_dir_read(php_stream *stream, char *buf, size_t count TSRMLS_D
|
||||
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, key.s, to_read);
|
||||
((php_stream_dirent *) buf)->d_name[to_read + 1] = '\0';
|
||||
|
||||
return sizeof(php_stream_dirent);
|
||||
@ -186,10 +186,11 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
|
||||
{
|
||||
HashTable *data;
|
||||
int dirlen = strlen(dir);
|
||||
char *save, *found, *key;
|
||||
zstr key;
|
||||
char *entry, *found, *save;
|
||||
uint keylen;
|
||||
ulong unused;
|
||||
char *entry;
|
||||
|
||||
ALLOC_HASHTABLE(data);
|
||||
zend_hash_init(data, 64, zend_get_hash_value, NULL, 0);
|
||||
|
||||
@ -204,7 +205,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
|
||||
break;
|
||||
}
|
||||
if (keylen <= (uint)dirlen) {
|
||||
if (keylen < (uint)dirlen || !strncmp(key, dir, dirlen)) {
|
||||
if (keylen < (uint)dirlen || !strncmp(key.s, dir, dirlen)) {
|
||||
if (SUCCESS != zend_hash_move_forward(manifest)) {
|
||||
break;
|
||||
}
|
||||
@ -213,27 +214,27 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
|
||||
}
|
||||
if (*dir == '/') {
|
||||
/* root directory */
|
||||
if (NULL != (found = (char *) memchr(key, '/', keylen))) {
|
||||
if (NULL != (found = (char *) memchr(key.s, '/', 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 - key.s, 1, 1);
|
||||
memcpy(entry, key.s, found - key.s);
|
||||
keylen = found - key.s;
|
||||
entry[keylen] = '\0';
|
||||
} else {
|
||||
entry = (char *) safe_emalloc(keylen, 1, 1);
|
||||
memcpy(entry, key, keylen);
|
||||
memcpy(entry, key.s, keylen);
|
||||
entry[keylen] = '\0';
|
||||
}
|
||||
goto PHAR_ADD_ENTRY;
|
||||
} else {
|
||||
if (0 != memcmp(key, dir, dirlen)) {
|
||||
if (0 != memcmp(key.s, dir, dirlen)) {
|
||||
/* entry in directory not found */
|
||||
if (SUCCESS != zend_hash_move_forward(manifest)) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
if (key[dirlen] != '/') {
|
||||
if (key.s[dirlen] != '/') {
|
||||
if (SUCCESS != zend_hash_move_forward(manifest)) {
|
||||
break;
|
||||
}
|
||||
@ -241,7 +242,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
|
||||
}
|
||||
}
|
||||
}
|
||||
save = key;
|
||||
save = key.s;
|
||||
save += dirlen + 1; /* seek to just past the path separator */
|
||||
if (NULL != (found = (char *) memchr(save, '/', keylen - dirlen - 1))) {
|
||||
/* is subdirectory */
|
||||
@ -289,7 +290,8 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char
|
||||
{
|
||||
php_url *resource = NULL;
|
||||
php_stream *ret;
|
||||
char *internal_file, *key, *error;
|
||||
char *internal_file, *error;
|
||||
zstr key;
|
||||
uint keylen;
|
||||
ulong unused;
|
||||
phar_archive_data *phar;
|
||||
@ -367,7 +369,7 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char
|
||||
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)) {
|
||||
if (keylen > (uint)i_len && 0 == memcmp(key.s, internal_file, i_len)) {
|
||||
/* directory found */
|
||||
internal_file = estrndup(internal_file,
|
||||
i_len);
|
||||
|
@ -655,7 +655,7 @@ notfound:
|
||||
goto stat_entry;
|
||||
} else {
|
||||
phar_archive_data *phar = *pphar;
|
||||
char *key;
|
||||
zstr key;
|
||||
uint keylen;
|
||||
ulong unused;
|
||||
|
||||
@ -667,11 +667,11 @@ notfound:
|
||||
if (HASH_KEY_NON_EXISTANT !=
|
||||
zend_hash_get_current_key_ex(
|
||||
&phar->manifest, &key, &keylen, &unused, 0, NULL)) {
|
||||
if (!memcmp(actual, key, actual_len)) {
|
||||
if (!memcmp(actual, key.s, actual_len)) {
|
||||
efree(save2);
|
||||
efree(entry);
|
||||
/* directory found, all dirs have the same stat */
|
||||
if (key[actual_len] == '/') {
|
||||
if (key.s[actual_len] == '/') {
|
||||
sb.st_size = 0;
|
||||
sb.st_mode = 0777;
|
||||
sb.st_mode |= S_IFDIR; /* regular directory */
|
||||
|
@ -1592,7 +1592,7 @@ woohoo:
|
||||
return FAILURE;
|
||||
}
|
||||
} else {
|
||||
char *key;
|
||||
zstr key;
|
||||
uint keylen;
|
||||
ulong unused;
|
||||
|
||||
@ -1606,7 +1606,7 @@ woohoo:
|
||||
zend_hash_move_forward(&(PHAR_GLOBALS->phar_fname_map));
|
||||
continue;
|
||||
}
|
||||
if (!memcmp(filename, key, keylen) && (filename_len == keylen
|
||||
if (!memcmp(filename, key.s, keylen) && (filename_len == keylen
|
||||
|| filename[keylen] == '/' || filename[keylen] == '\0')) {
|
||||
if (FAILURE == zend_hash_get_current_data(&(PHAR_GLOBALS->phar_fname_map), (void **) &pphar)) {
|
||||
break;
|
||||
@ -2850,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) {
|
||||
/* 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;
|
||||
|
@ -778,7 +778,7 @@ PHP_METHOD(Phar, webPhar)
|
||||
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, key.s, keylen-1, (void *)&mime, sizeof(phar_mime_type), NULL);
|
||||
|
||||
if (mimeoverride) {
|
||||
if (!zend_hash_num_elements(Z_ARRVAL_P(mimeoverride))) {
|
||||
@ -786,7 +786,7 @@ 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))) {
|
||||
zval **val;
|
||||
char *key;
|
||||
zstr 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)) {
|
||||
@ -798,7 +798,7 @@ PHP_METHOD(Phar, webPhar)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
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\"", key.s);
|
||||
phar_entry_delref(phar TSRMLS_CC);
|
||||
#ifdef PHP_WIN32
|
||||
efree(fname);
|
||||
@ -1315,7 +1315,8 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
|
||||
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;
|
||||
zstr str_key;
|
||||
zend_class_entry *ce = p_obj->c;
|
||||
phar_archive_object *phar_obj = p_obj->p;
|
||||
char *str = "[stream]";
|
||||
@ -1347,8 +1348,8 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
|
||||
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;
|
||||
}
|
||||
save = str_key;
|
||||
if (str_key[str_key_len - 1] == '\0') str_key_len--;
|
||||
save = str_key.s;
|
||||
if (str_key.s[str_key_len - 1] == '\0') str_key_len--;
|
||||
} else {
|
||||
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;
|
||||
@ -1393,7 +1394,7 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
|
||||
goto phar_spl_fileinfo;
|
||||
case SPL_FS_INFO:
|
||||
case SPL_FS_FILE:
|
||||
fname = expand_filepath(intern->file_name, NULL TSRMLS_CC);
|
||||
fname = expand_filepath(intern->file_name.s, NULL TSRMLS_CC);
|
||||
fname_len = strlen(fname);
|
||||
save = fname;
|
||||
is_splfileinfo = 1;
|
||||
@ -1423,9 +1424,9 @@ phar_spl_fileinfo:
|
||||
}
|
||||
return ZEND_HASH_APPLY_KEEP;
|
||||
}
|
||||
str_key = fname + base_len;
|
||||
if (*str_key == '/' || *str_key == '\\') {
|
||||
str_key++;
|
||||
str_key.s = fname + base_len;
|
||||
if (*str_key.s == '/' || *str_key.s == '\\') {
|
||||
str_key.s++;
|
||||
str_key_len--;
|
||||
}
|
||||
} else {
|
||||
@ -1446,8 +1447,8 @@ phar_spl_fileinfo:
|
||||
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;
|
||||
}
|
||||
save = str_key;
|
||||
if (str_key[str_key_len - 1] == '\0') str_key_len--;
|
||||
save = str_key.s;
|
||||
if (str_key.s[str_key_len - 1] == '\0') str_key_len--;
|
||||
} else {
|
||||
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;
|
||||
@ -1491,8 +1492,8 @@ phar_spl_fileinfo:
|
||||
}
|
||||
|
||||
after_open_fp:
|
||||
if (!(data = phar_get_or_create_entry_data(phar_obj->arc.archive->fname, phar_obj->arc.archive->fname_len, str_key, str_key_len, "w+b", 0, &error TSRMLS_CC))) {
|
||||
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s cannot be created: %s", str_key, error);
|
||||
if (!(data = phar_get_or_create_entry_data(phar_obj->arc.archive->fname, phar_obj->arc.archive->fname_len, str_key.s, str_key_len, "w+b", 0, &error TSRMLS_CC))) {
|
||||
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s cannot be created: %s", str_key.s, error);
|
||||
efree(error);
|
||||
if (save) {
|
||||
efree(save);
|
||||
@ -1514,7 +1515,7 @@ after_open_fp:
|
||||
php_stream_close(fp);
|
||||
}
|
||||
|
||||
add_assoc_string(p_obj->ret, str_key, opened, 0);
|
||||
add_assoc_string(p_obj->ret, str_key.s, opened, 0);
|
||||
|
||||
if (save) {
|
||||
efree(save);
|
||||
|
@ -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_url *resource = NULL;
|
||||
char *internal_file, *key, *error;
|
||||
zstr key;
|
||||
char *internal_file, *error;
|
||||
uint keylen;
|
||||
ulong unused;
|
||||
phar_archive_data *phar;
|
||||
@ -562,9 +563,9 @@ 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->manifest, &key, &keylen, &unused, 0, NULL)) {
|
||||
if (keylen >= (uint)internal_file_len && 0 == memcmp(internal_file, key, internal_file_len)) {
|
||||
if (keylen >= (uint)internal_file_len && 0 == memcmp(internal_file, key.s, internal_file_len)) {
|
||||
/* directory found, all dirs have the same stat */
|
||||
if (key[internal_file_len] == '/') {
|
||||
if (key.s[internal_file_len] == '/') {
|
||||
phar_dostat(phar, NULL, ssb, 1, phar->alias, phar->alias_len TSRMLS_CC);
|
||||
php_url_free(resource);
|
||||
return SUCCESS;
|
||||
@ -577,7 +578,7 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags,
|
||||
}
|
||||
/* check for mounted directories */
|
||||
if (phar->mounted_dirs.arBuckets && zend_hash_num_elements(&phar->mounted_dirs)) {
|
||||
char *key;
|
||||
zstr key;
|
||||
ulong unused;
|
||||
uint keylen;
|
||||
|
||||
@ -586,7 +587,7 @@ 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)) {
|
||||
break;
|
||||
}
|
||||
if ((int)keylen >= internal_file_len || strncmp(key, internal_file, keylen)) {
|
||||
if ((int)keylen >= internal_file_len || strncmp(key.s, internal_file, keylen)) {
|
||||
continue;
|
||||
} else {
|
||||
char *test;
|
||||
@ -594,7 +595,7 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags,
|
||||
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, key.s, keylen, (void **) &entry)) {
|
||||
goto free_resource;
|
||||
}
|
||||
if (!entry->tmp || !entry->is_mounted) {
|
||||
|
@ -36,7 +36,7 @@ foreach($files as $name => $cont)
|
||||
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
|
||||
|
@ -1183,7 +1183,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
|
||||
}
|
||||
return entry;
|
||||
} else if (phar->mounted_dirs.arBuckets && zend_hash_num_elements(&phar->mounted_dirs)) {
|
||||
char *key;
|
||||
zstr key;
|
||||
ulong unused;
|
||||
uint keylen;
|
||||
|
||||
@ -1192,7 +1192,7 @@ 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)) {
|
||||
break;
|
||||
}
|
||||
if ((int)keylen >= path_len || strncmp(key, path, keylen)) {
|
||||
if ((int)keylen >= path_len || strncmp(key.s, path, keylen)) {
|
||||
continue;
|
||||
} else {
|
||||
char *test;
|
||||
@ -1200,15 +1200,15 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
|
||||
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, key.s, 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", key.s);
|
||||
}
|
||||
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", key.s);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -1254,7 +1254,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
|
||||
if (dir) {
|
||||
/* try to find a directory */
|
||||
HashTable *manifest;
|
||||
char *key;
|
||||
zstr key;
|
||||
uint keylen;
|
||||
ulong unused;
|
||||
|
||||
@ -1267,14 +1267,14 @@ 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)) {
|
||||
break;
|
||||
}
|
||||
if (0 != memcmp(key, path, path_len)) {
|
||||
if (0 != memcmp(key.s, path, path_len)) {
|
||||
/* entry in directory not found */
|
||||
if (SUCCESS != zend_hash_move_forward(manifest)) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
if (key[path_len] != '/') {
|
||||
if (key.s[path_len] != '/') {
|
||||
if (SUCCESS != zend_hash_move_forward(manifest)) {
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user