summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Beaver <cellog@php.net>2008-01-12 22:16:00 +0000
committerGreg Beaver <cellog@php.net>2008-01-12 22:16:00 +0000
commit56e84a390ca548a431aef4642f2c45e26d6949a5 (patch)
treec802fdbdb816fdcd1d4f77b13016dc81bdcd2d32
parent27fa0688cc7ed715c96a4ed23aac62ec76eb3bf3 (diff)
downloadphp-git-56e84a390ca548a431aef4642f2c45e26d6949a5.tar.gz
fix segfault in Phar::webPhar() if file is in root directory, found in frontcontroller16.phpt
-rwxr-xr-xext/phar/phar_object.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index aae4e82972..5a84b4c4a8 100755
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -306,7 +306,11 @@ static int phar_file_action(phar_entry_data *phar, char *mime_type, int code, ch
PHAR_G(cwd_len) = 0;
if (zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL)==SUCCESS) {
if ((cwd = strrchr(entry, '/'))) {
- if (entry[0] == '/') {
+ if (entry == cwd) {
+ /* root directory */
+ PHAR_G(cwd_len) = 0;
+ PHAR_G(cwd) = NULL;
+ } else if (entry[0] == '/') {
PHAR_G(cwd_len) = cwd - (entry + 1);
PHAR_G(cwd) = estrndup(entry + 1, PHAR_G(cwd_len));
} else {