Skip to content

Commit

Permalink
project: launch subprocesses without shell
Browse files Browse the repository at this point in the history
In the Project method set_new_manifest_rev, the _update_manifest_rev
helper function tries to run the following git command:

  git update-ref -m .. refs/heads/ref <commit-id>^{commit}

However, on Msys2's MinGW build of python handles the escaping of
"...^{commit}" incorrectly, converting it into "...commit".

This issue highlights the pitfalls of using the Python subprocess
module's shell=True option, which can apply string conversions to
commands that are unexpected by the calling code.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
  • Loading branch information
jhol committed Feb 26, 2025
1 parent b75b86b commit 4d5387e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/west/app/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1731,8 +1731,7 @@ def do_run(self, args, user_args):

self.banner(
f'running "{args.subcommand}" in {project.name_and_path}:')
rc = subprocess.Popen(args.subcommand, shell=True, env=env,
cwd=cwd).wait()
rc = subprocess.Popen(args.subcommand, env=env, cwd=cwd).wait()
if rc:
failed.append(project)
self._handle_failed(args, failed)
Expand Down

0 comments on commit 4d5387e

Please sign in to comment.