From 1b39f39657d2e58f8ec57341581a39bbf0be645b Mon Sep 17 00:00:00 2001
From: "djm@openbsd.org" <djm@openbsd.org>
Date: Mon, 29 Jun 2026 01:47:21 +0000
Subject: [PATCH] upstream: avoid download to server-controlled path when
 performing

download on the commandline. From Swival scanner

OpenBSD-Commit-ID: d1b2c44305fdfe6d51eed9ecc727e59478bf311f
---
 sftp.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

--- a/sftp.c
+++ b/sftp.c
@@ -2181,13 +2181,8 @@ interactive_loop(struct sftp_conn *conn,
 				return (-1);
 			}
 		} else {
-			/* XXX this is wrong wrt quoting */
-			snprintf(cmd, sizeof cmd, "get%s %s%s%s",
-			    global_aflag ? " -a" : "", dir,
-			    file2 == NULL ? "" : " ",
-			    file2 == NULL ? "" : file2);
-			err = parse_dispatch_command(conn, cmd,
-			    &remote_path, startdir, 1, 0);
+			err = process_get(conn, dir, file2, remote_path, 0, 0,
+			    global_aflag, 0);
 			free(dir);
 			free(startdir);
 			free(remote_path);
