Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Process] fixed uppercase ARGC and ARGV should also be skipped #44538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2021

Conversation

rbaarsma
Copy link
Contributor

@rbaarsma rbaarsma commented Dec 9, 2021

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #44534
License MIT
Doc PR no

uppercase env ARGC and ARGV were showing a warning:

[09-Dec-2021 17:17:05 Europe/Amsterdam] PHP Warning:  Array to string conversion in /var/www/app/vendor/symfony/process/Process.php on line 344

This PR fixes that by adding upon the existing functionality blocking argv and argc env vars to become part of the eventual env vars.

@carsonbot
Copy link

Hey!

I think @andrei0x309 has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you figure out where this uppercase ARGV comes from in your case? It looks like a buggy code. Yes, we were allowing it before, but this was not legit to me.

@@ -340,7 +340,7 @@ public function start(callable $callback = null, array $env = [])

$envPairs = [];
foreach ($env as $k => $v) {
if (false !== $v && 'argc' !== $k && 'argv' !== $k) {
if (false !== $v && false === \in_array(strtolower($k), ['argc', 'argv'], true)) {
Copy link
Member

@nicolas-grekas nicolas-grekas Dec 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer not calling strtolower for that. Let's use this instead if you don't mind:
if (false !== $v && false === \in_array($k, ['argc', 'argv', 'ARGC', 'ARGV'], true)) {

@fabpot
Copy link
Member

fabpot commented Dec 11, 2021

Thank you @rbaarsma.

@fabpot fabpot merged commit ac3631a into symfony:4.4 Dec 11, 2021
@rbaarsma
Copy link
Contributor Author

rbaarsma commented Dec 12, 2021

Can you figure out where this uppercase ARGV comes from in your case? It looks like a buggy code. Yes, we were allowing it before, but this was not legit to me.

@nicolas-grekas I haven't fully debugged how, but it was coming from liuggio/fastest, which executes unit tests in parallel processes. I can dive in deeper that maybe they are doing it wrong and shouldn't do it, but still that should not break Symfony I guess ;)

Also see the related issue on how to reproduce

@rbaarsma rbaarsma deleted the issue-44534 branch December 14, 2021 16:05
This was referenced Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants