System call functions sometimes treat the last line in a multi-line command as a separate command
Nobody has claimed this yet.
- Dominant language
- XML
- Stars
- 596
- Forks
- 890
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 55
Description
From manual page: https://php.net/function.exec
function argon2idKey(string $password, string $salt): string
{
$innerCommand =
'echo ' . escapeshellarg($password) . ' | \\' . "\n"
. ' argon2 $(echo ' . escapeshellarg(base64_encode($salt)) . ' | base64 -d) -id -l 32 \\' . "\n"
. ' -t 1 \\' . "\n"
. ' -m 16 \\' . "\n"
. ' -p 4 \\ ' . "\n"
. ' -r';
$command = 'bash -c ' . escapeshellarg($innerCommand);
echo $command;
return exec($command);
}
The output contains "bash: line 6: -r: command not found". If the output of echo $command; is copied/pasted into the console and ran as-is, it will execute normally. If the -r argument is placed together with -p 4 becoming . ' -p 4 -r', exec() will execute the command with no issues.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Begin with the linked exec() manual page and run the provided PHP/bash reproduction, comparing exec() with the interactive shell behavior. Done means the differing treatment of the final line is explained and the appropriate documentation or implementation follow-up is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, php
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100