File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2740,16 +2740,17 @@ phpvm_alias() {
27402740 return " $PHPVM_EXIT_INVALID_ARG "
27412741 fi
27422742
2743- # Validate version format BEFORE using it in path check (security)
2744- # This prevents path traversal attacks with malicious version strings
2745- if ! validate_php_version " $version " ; then
2746- phpvm_err " Invalid PHP version format: $version "
2743+ # Check if target is an alias BEFORE version validation
2744+ # This gives a better error message for alias chains
2745+ # Use phpvm_validate_alias_name first to ensure safe file access
2746+ if phpvm_validate_alias_name " $version " 2> /dev/null && [ -f " $PHPVM_DIR /alias/$version " ]; then
2747+ phpvm_err " Alias target '$version ' is itself an alias. Please point aliases directly to a PHP version."
27472748 return " $PHPVM_EXIT_INVALID_ARG "
27482749 fi
27492750
2750- # Now safe to check if target is an alias (version format is validated )
2751- if [ -f " $PHPVM_DIR /alias/ $ version" ] ; then
2752- phpvm_err " Alias target ' $ version' is itself an alias. Please point aliases directly to a PHP version. "
2751+ # Validate version format (security: prevents path traversal attacks )
2752+ if ! validate_php_version " $version " ; then
2753+ phpvm_err " Invalid PHP version format: $ version"
27532754 return " $PHPVM_EXIT_INVALID_ARG "
27542755 fi
27552756
You can’t perform that action at this time.
0 commit comments