]> granicus.if.org Git - php/commitdiff
add another test for alias overloading and make sure we disallow it when passed in...
authorGreg Beaver <cellog@php.net>
Wed, 16 Apr 2008 03:42:29 +0000 (03:42 +0000)
committerGreg Beaver <cellog@php.net>
Wed, 16 Apr 2008 03:42:29 +0000 (03:42 +0000)
ext/phar/phar.c
ext/phar/tests/phar_setalias2.phpt

index a36e87df65ef78d8714c8ff8d809aac7d4b90fbd..232ecca52817e1cb5f52b074439d31375fb67fa8 100644 (file)
@@ -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;
 }
index b6679b893af4de2aa08475953cfc32fd5a62af02..44c8e5b465daaffb9125cabd3eea71a6334b6d93 100644 (file)
@@ -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===