Skip to content

Commit

Permalink
escape file names passed through ssh
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Hars authored and Florian Hars committed Jul 25, 2024
1 parent 8599a03 commit ca8929f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions labgrid/driver/usbstoragedriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pathlib
import time
import subprocess
import shlex

import attr

Expand Down Expand Up @@ -96,14 +97,14 @@ def write_files(self, sources, target, partition, target_is_directory=True):
# (pathlib.PurePath(...) / "/") == "/", so we turn absolute paths into relative
# paths with respect to the mount point here
target_rel = target.relative_to(target.root) if target.root is not None else target
target_path = str(pathlib.PurePath(mount_path) / target_rel)
target_path = shlex.quote(str(pathlib.PurePath(mount_path) / target_rel))

copied_sources = []

for f in sources:
mf = ManagedFile(f, self.storage)
mf.sync_to_resource()
copied_sources.append(mf.get_remote_path())
copied_sources.append(shlex.quote(mf.get_remote_path()))

if target_is_directory:
args = ["cp", "-t", target_path] + copied_sources
Expand Down

0 comments on commit ca8929f

Please sign in to comment.