]> granicus.if.org Git - php/commitdiff
fix segfault in Phar::webPhar() if file is in root directory, found in frontcontrolle...
authorGreg Beaver <cellog@php.net>
Sat, 12 Jan 2008 22:16:00 +0000 (22:16 +0000)
committerGreg Beaver <cellog@php.net>
Sat, 12 Jan 2008 22:16:00 +0000 (22:16 +0000)
ext/phar/phar_object.c

index aae4e82972b8e106b2d0a200f094e19c4d71604d..5a84b4c4a8e78398cc8ff4b7d16e1bbf2abb508d 100755 (executable)
@@ -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 {