Explorar el Código

fix(idf_tools): execution of empty command in get_version()

The ticket below reports some very strange behaviour, where
even a simple command like the following

python3 -c "import subprocess; subprocess.run([''])"

actually spawns some process and pass instead of raising
PermissionError. Even though the problem is most probably somewhere
else, not in idf_tools, we may just return early if there is no
command available for get_version().

Closes https://github.com/espressif/esp-idf/issues/11880

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
Frantisek Hrbata hace 2 años
padre
commit
bf1a487b73
Se han modificado 1 ficheros con 7 adiciones y 0 borrados
  1. 7 0
      tools/idf_tools.py

+ 7 - 0
tools/idf_tools.py

@@ -689,6 +689,13 @@ class IDFTool(object):
         cmd = self._current_options.version_cmd  # type: ignore
         if executable_path:
             cmd[0] = executable_path
+
+        if not cmd[0]:
+            # There is no command available, so return early. It seems that
+            # within some very strange context empty [''] may actually execute
+            # something https://github.com/espressif/esp-idf/issues/11880
+            raise ToolNotFound('Tool {} not found'.format(self.name))
+
         try:
             version_cmd_result = run_cmd_check_output(cmd, None, extra_paths)
         except OSError: