From 3e7b1288a43ecaaffc38925ae4c12cbeb1e56b1e Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@debian.org>
Date: Tue, 2 Dec 2025 10:29:10 +0000
Subject: scp: Quote filenames in verbose mode

This is less misleading if there are any shell metacharacters.

Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=3900
Bug-Ubuntu: https://bugs.launchpad.net/bugs/89945
Forwarded: https://bugzilla.mindrot.org/show_bug.cgi?id=3900
Last-Update: 2025-12-02

Patch-Name: scp-quoting.patch
---
 scp.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/scp.c b/scp.c
index c5f573cc1..e141362c6 100644
--- a/scp.c
+++ b/scp.c
@@ -216,7 +216,7 @@ suspchild(int signo)
 static int
 do_local_cmd(arglist *a)
 {
-	u_int i;
+	char *args;
 	int status;
 	pid_t pid;
 
@@ -224,10 +224,9 @@ do_local_cmd(arglist *a)
 		fatal("do_local_cmd: no arguments");
 
 	if (verbose_mode) {
-		fprintf(stderr, "Executing:");
-		for (i = 0; i < a->num; i++)
-			fmprintf(stderr, " %s", a->list[i]);
-		fprintf(stderr, "\n");
+		args = argv_assemble(a->num, a->list);
+		fmprintf(stderr, "Executing: %s\n", args);
+		free(args);
 	}
 	if ((pid = fork()) == -1)
 		fatal("do_local_cmd: fork: %s", strerror(errno));
