From: Pierre Joye Date: Thu, 24 Aug 2006 17:31:20 +0000 (+0000) Subject: - MFB: solve the relative path issues in TS environment X-Git-Tag: RELEASE_1_0_0RC1~1886 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=296cef95706cae25ed7653fe64d08257255c4fc2;p=php - MFB: solve the relative path issues in TS environment --- diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 9fb12d5578..081e67916f 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -862,6 +862,7 @@ ZIPARCHIVE_METHOD(open) int filename_len; int err = 0; long flags = 0; + char resolved_path[MAXPATHLEN + 1]; zval *this = getThis(); ze_zip_object *ze_obj = NULL; @@ -880,6 +881,11 @@ ZIPARCHIVE_METHOD(open) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty string as source"); RETURN_FALSE; } + + if (!VCWD_REALPATH(filename, resolved_path)) { + RETURN_FALSE; + } + if (ze_obj->za) { /* we already have an opened zip, free it */ zip_close(ze_obj->za); @@ -888,7 +894,7 @@ ZIPARCHIVE_METHOD(open) efree(ze_obj->filename); } - intern = zip_open(filename, flags, &err); + intern = zip_open(resolved_path, flags, &err); if (!intern || err) { RETURN_LONG((long)err); } @@ -941,6 +947,7 @@ ZIPARCHIVE_METHOD(addFile) struct zip_source *zs; long offset_start = 0, offset_len = 0; int cur_idx; + char resolved_path[MAXPATHLEN + 1]; if (!this) { RETURN_FALSE; @@ -964,7 +971,11 @@ ZIPARCHIVE_METHOD(addFile) entry_name_len = filename_len; } - zs = zip_source_file(intern, filename, 0, 0); + if (!VCWD_REALPATH(filename, resolved_path)) { + RETURN_FALSE; + } + + zs = zip_source_file(intern, resolved_path, 0, 0); if (!zs) { RETURN_FALSE; }