note 50229 deleted from function.exec by cmb
| From: | cmb@php.net | Date: | Sun, 24 Nov 2019 08:38:00 +0000 |
| Subject: | note 50229 deleted from function.exec by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213190@lists.php.net to get a copy of this message | ||
Note Submitter: david houlder
----
The note regarding how exec() works under safe_mode is wrong.
echo y | echo x does not become echo "y | echo x". It essentially becomes echo
"y" "|" "echo" "x". The entire string is passed through
escapeshellcmd(), which effectively splits arguments at spaces. Note that this makes it impossible
to reliably pass arguments containing spaces to exec() in safe_mode. Since 4.3.3 escapeshellcmd()
tries to pass quoted arguments through (so you could try exec("cmd 'arg 1' 'arg
2'")), but not on win32, and will still wrongly backslash escape any punctuation
characters inside the quotes.
Not only can the path not contain '..' components, but no directory or filename can
contain the string '..'. e.g. /path/to/my..executable will refuse to run.