mirror of
https://github.com/openssh/openssh-portable.git
synced 2026-01-12 00:04:08 +08:00
upstream: similar to scp, fix implicit destination path selection
when source path ends with ".."; ok deraadt@ OpenBSD-Commit-ID: 9b8d2a662d96b241293a88b3ea21f2419bfc4812
This commit is contained in:
committed by
Damien Miller
parent
6432b9f6a2
commit
4f14ca8633
9
sftp.c
9
sftp.c
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sftp.c,v 1.246 2025/10/08 21:48:40 djm Exp $ */
|
||||
/* $OpenBSD: sftp.c,v 1.247 2025/10/13 00:54:29 djm Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
|
||||
*
|
||||
@@ -679,6 +679,10 @@ process_get(struct sftp_conn *conn, const char *src, const char *dst,
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Special handling for dest of '..' */
|
||||
if (strcmp(filename, "..") == 0)
|
||||
filename = "."; /* Download to dest, not dest/.. */
|
||||
|
||||
if (g.gl_matchc == 1 && dst) {
|
||||
if (local_is_dir(dst)) {
|
||||
abs_dst = sftp_path_append(dst, filename);
|
||||
@@ -773,6 +777,9 @@ process_put(struct sftp_conn *conn, const char *src, const char *dst,
|
||||
err = -1;
|
||||
goto out;
|
||||
}
|
||||
/* Special handling for source of '..' */
|
||||
if (strcmp(filename, "..") == 0)
|
||||
filename = "."; /* Upload to dest, not dest/.. */
|
||||
|
||||
free(abs_dst);
|
||||
abs_dst = NULL;
|
||||
|
||||
Reference in New Issue
Block a user