-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Child process' execFile
and execFileSync
handle arguments different when shell is not falsy
#43333
Comments
For the record: also happens with CJS. |
This is caused by This issue can be assigned to me. |
Could you help me understand why the behavior of execFileSync is expected? If $ bash -c "echo foo bar"
foo bar |
@F3n67u Your understanding is correct, but now execFileSync interprets |
No need to wait for someone to assign you to the issue, feel free to send the PR when your patch is ready. :) |
That's based on @bnoordhuis' comments in #29466.
That is actually the topic of the discussion I brought up over at #29466 as well. |
Due to a bug with `execFileSync` [1], arguments passed to it when used in combination with the `shell: true` option won't be used on certain shells. Notably, this includes many Unix shells (such as Bash). Luckily, for the purposes of this project, `spawnSync` can be used instead. -- 1. nodejs/node#43333
PR-URL: #43345 Fixes: #43333 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]>
PR-URL: #43345 Fixes: #43333 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]>
PR-URL: nodejs#43345 Fixes: nodejs#43333 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]>
Since, per [1], it's not actually guaranteed these work the same. -- 1. nodejs/node#43333
* Get fuzz shell once per fuzz target * Handle errors explicitly in fuzz targets * Extract argument escaping/quoting out of invocation Should make for easier overall reading and aligns all fuzz targets with the style of `exec.test.cjs`. * Test both sync and callback versions of explicitly Since, per [1], it's not actually guaranteed these work the same. * Remove multiple argument versions of checks I do not believe these currently provide significant value. They don't seem to test anything special about multiple arguments. Plus the method by which these convert the buffer into multiple args leaves a lot to be desired. An upside is that fuzzing should become more efficient as less cycles are wasted on testing something with little to no value. -- 1. nodejs/node#43333
Version
v18.3.0
Platform
Linux *** 5.13.0-44-generic #49~20.04.1-Ubuntu SMP *** x86_64 x86_64 x86_64 GNU/Linux
Subsystem
node:child_process
What steps will reproduce the bug?
options
object includes a non-falsy value for theshell
option. (for reference, see thechild_process.execFile
documentation).args
argument toexecFile(Sync)
after normalization:How often does it reproduce? Is there a required condition?
It always reproduces.
What is the expected behavior?
child_process.execFileSync
andchild_process.execFile
invoke commands in the same way given the same arguments. In particular, I believe the behaviour ofexecFileSync
is expected.What do you see instead?
child_process.execFileSync
andchild_process.execFile
invoke commands in different ways given the same arguments.Additional information
This bug reports follows from a discussion in #29466 - in particular the discussion starting with this comment of mine. This bug report is based on @bnoordhuis' comment in that thread.
I tested and was able to reproduce this bug on Node v16.15.0 and v18.3.0.
The text was updated successfully, but these errors were encountered: