[openssh-commits] [openssh] 01/05: upstream: when using the SFTP protocol for transfers, fix implicit

git+noreply at mindrot.org git+noreply at mindrot.org
Mon Oct 13 11:57:24 AEDT 2025


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit 6432b9f6a216d0f5fb43df500e9bc30bebb3f58b
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Mon Oct 13 00:53:51 2025 +0000

    upstream: when using the SFTP protocol for transfers, fix implicit
    
    destination path selection when source path ends with ".."; ok deraadt@
    bz3871
    
    OpenBSD-Commit-ID: d75b3b006386c5302ed4f67c4add18464ab36a0b
---
 scp.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/scp.c b/scp.c
index c5f573cc1..85880a792 100644
--- a/scp.c
+++ b/scp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scp.c,v 1.268 2025/09/25 06:23:19 jsg Exp $ */
+/* $OpenBSD: scp.c,v 1.269 2025/10/13 00:53:51 djm Exp $ */
 /*
  * scp - secure remote copy.  This is basically patched BSD rcp which
  * uses ssh to do the data transfer (instead of using rcmd).
@@ -1340,6 +1340,10 @@ source_sftp(int argc, char *src, char *targ, struct sftp_conn *conn)
 	if ((filename = basename(src)) == NULL)
 		fatal("basename \"%s\": %s", src, strerror(errno));
 
+	/* Special handling for source of '..' */
+	if (strcmp(filename, "..") == 0)
+		filename = "."; /* Upload to dest, not dest/.. */
+
 	/*
 	 * No need to glob here - the local shell already took care of
 	 * the expansions
@@ -1613,6 +1617,10 @@ sink_sftp(int argc, char *dst, const char *src, struct sftp_conn *conn)
 			goto out;
 		}
 
+		/* Special handling for destination of '..' */
+		if (strcmp(filename, "..") == 0)
+			filename = "."; /* Download to dest, not dest/.. */
+
 		if (dst_is_dir)
 			abs_dst = sftp_path_append(dst, filename);
 		else

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list