fix bad pointer cast in ext/phar, fix segfault and failed tests (bigendian)

This commit is contained in:
Remi Collet 2014-12-16 09:31:20 +01:00
parent 62691b2d6a
commit 5c0e118573
2 changed files with 8 additions and 7 deletions

View File

@ -339,7 +339,7 @@ PHAR_FUNC(phar_fopen) /* {{{ */
}
if (use_include_path || (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://"))) {
char *arch, *entry, *fname;
size_t arch_len, entry_len, fname_len;
int arch_len, entry_len, fname_len;
php_stream_context *context = NULL;
char *name;
phar_archive_data *phar;
@ -349,7 +349,7 @@ PHAR_FUNC(phar_fopen) /* {{{ */
goto skip_phar;
}
fname_len = strlen(fname);
if (FAILURE == phar_split_fname(fname, fname_len, &arch, (int *)&arch_len, &entry, (int *)&entry_len, 2, 0 TSRMLS_CC)) {
if (FAILURE == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0 TSRMLS_CC)) {
goto skip_phar;
}
@ -371,7 +371,7 @@ PHAR_FUNC(phar_fopen) /* {{{ */
name = entry;
}
} else {
entry = phar_fix_filepath(estrndup(entry, entry_len), (int *)&entry_len, 1 TSRMLS_CC);
entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1 TSRMLS_CC);
if (entry[0] == '/') {
if (!zend_hash_str_exists(&(phar->manifest), entry + 1, entry_len - 1)) {
/* this file is not in the phar, use the original path */

9
ext/phar/phar_object.c Normal file → Executable file
View File

@ -546,7 +546,8 @@ PHP_METHOD(Phar, webPhar)
{
zval *mimeoverride = NULL, *rewrite = NULL;
char *alias = NULL, *error, *index_php = NULL, *f404 = NULL, *ru = NULL;
size_t alias_len = 0, f404_len = 0, free_pathinfo = 0, ru_len = 0;
size_t alias_len = 0, f404_len = 0, free_pathinfo = 0;
int ru_len = 0;
char *fname, *path_info, *mime_type = NULL, *entry, *pt;
const char *basename;
size_t fname_len, index_php_len = 0;
@ -729,7 +730,7 @@ PHP_METHOD(Phar, webPhar)
}
if (entry_len) {
phar_postprocess_ru_web(fname, fname_len, &entry, (int *)&entry_len, &ru, (int *)&ru_len TSRMLS_CC);
phar_postprocess_ru_web(fname, fname_len, &entry, &entry_len, &ru, &ru_len TSRMLS_CC);
}
if (!entry_len || (entry_len == 1 && entry[0] == '/')) {
@ -1999,7 +2000,7 @@ static zend_object *phar_rename_archive(phar_archive_data *phar, char *ext, zend
zend_class_entry *ce;
char *error;
const char *pcr_error;
size_t ext_len = ext ? strlen(ext) : 0;
int ext_len = ext ? strlen(ext) : 0;
int oldname_len;
phar_archive_data *pphar = NULL;
php_stream_statbuf ssb;
@ -2050,7 +2051,7 @@ static zend_object *phar_rename_archive(phar_archive_data *phar, char *ext, zend
ext = "phar";
}
}
} else if (phar_path_check(&ext, (int *)&ext_len, &pcr_error) > pcr_is_ok) {
} else if (phar_path_check(&ext, &ext_len, &pcr_error) > pcr_is_ok) {
if (phar->is_data) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "data phar converted from \"%s\" has invalid extension %s", phar->fname, ext);