php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30404 wrong behaviour with escaped commands in safemode
Submitted: 2004-10-11 22:59 UTC Modified: 2004-12-12 01:51 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: php-bug at angehrn dot com Assigned:
Status: Not a bug Package: Program Execution
PHP Version: 4.3.9 OS: Linux
Private report: No CVE-ID: None
 [2004-10-11 22:59 UTC] php-bug at angehrn dot com
Description:
------------
if safe_mode is on, i cannot use a command with backslash escaped commands in exec()

Reproduce code:
---------------
safe_mode off

exec('convert logo: "test 1.jpg"'); - works
exec('convert logo: test\ 1.jpg'); - works

safe_mode on

exec('convert logo: "test 1.jpg"'); - works
exec('convert logo: test\ 1.jpg'); - fails

Expected result:
----------------
it should work like the command with safemode off

Actual result:
--------------
it fails...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-23 17:49 UTC] php-bug at angehrn dot com
with a small shell script, you can reproduce the wrong behaviour:

Reproduce code:
---------------

test.php:
----
<?php
exec('./test_script "test 1.jpg"',$array1,$return1);
exec('./test_script test\ 1.jpg', $array2,$return2);

echo '<pre>';
echo $return1;
print_r($array1);

echo '<br /><br />';
echo $return2;
print_r($array2);

echo '</pre>';
?>
----

test_script:
----
#!/bin/sh
echo $1
echo $2
exit 0
----


Expected result:
----------------
0Array
(
    [0] => test 1.jpg
    [1] => 
)


0Array
(
    [0] => test 1.jpg
    [1] => 
)



Actual result:
--------------

0Array
(
    [0] => test 1.jpg
    [1] => 
)


0Array
(
    [0] => test\
    [1] => 1.jpg
)
 [2004-12-12 01:51 UTC] sniper@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

In safe-mode the commands passed to exec() are always escaped. 
See http://www.php.net/manual/en/function.escapeshellcmd.php
for more information.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 11:01:28 2024 UTC