From: Greg Beaver Date: Wed, 16 Apr 2008 03:42:29 +0000 (+0000) Subject: add another test for alias overloading and make sure we disallow it when passed in... X-Git-Tag: RELEASE_2_0_0b1~362 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6387155b3d188f97aeb2b8c2e9346fe879f3ffa5;p=php add another test for alias overloading and make sure we disallow it when passed in constructor --- diff --git a/ext/phar/phar.c b/ext/phar/phar.c index a36e87df65..232ecca528 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -1172,7 +1172,14 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a phar_request_initialize(TSRMLS_C); zend_hash_add(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len, (void*)&mydata, sizeof(phar_archive_data*), NULL); if (register_alias) { - zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL); + if (FAILURE == zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL)) { + if (options & REPORT_ERRORS) { + if (error) { + spprintf(error, 0, "archive \"%s\" cannot be associated with alias \"%s\", already in use", fname, alias); + } + } + return FAILURE; + } } return SUCCESS; } diff --git a/ext/phar/tests/phar_setalias2.phpt b/ext/phar/tests/phar_setalias2.phpt index b6679b893a..44c8e5b465 100644 --- a/ext/phar/tests/phar_setalias2.phpt +++ b/ext/phar/tests/phar_setalias2.phpt @@ -28,6 +28,11 @@ try { } catch (Exception $e) { echo $e->getMessage() . "\n"; } +try { + $b = new Phar(dirname(__FILE__) . '/nope.phar', 0, 'test'); +} catch (Exception $e) { + echo $e->getMessage() . "\n"; +} ?> ===DONE=== --CLEAN-- @@ -41,4 +46,5 @@ __HALT_COMPILER(); hio test alias "test" is already used for archive "%sphar_setalias2.phar.php" and cannot be used for other archives +archive "%snope.phar" cannot be associated with alias "test", already in use ===DONE===