=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/scp.c,v retrieving revision 1.226 retrieving revision 1.227 diff -u -r1.226 -r1.227 --- src/usr.bin/ssh/scp.c 2021/08/09 23:44:32 1.226 +++ src/usr.bin/ssh/scp.c 2021/08/09 23:47:44 1.227 @@ -1,4 +1,4 @@ -/* $OpenBSD: scp.c,v 1.226 2021/08/09 23:44:32 djm Exp $ */ +/* $OpenBSD: scp.c,v 1.227 2021/08/09 23:47:44 djm Exp $ */ /* * scp - secure remote copy. This is basically patched BSD rcp which * uses ssh to do the data transfer (instead of using rcmd). @@ -1222,10 +1222,14 @@ /* Canonicalise a remote path, handling ~ by assuming cwd is the homedir */ static char * -absolute_remote_path(const char *path, const char *remote_path) +absolute_remote_path(struct sftp_conn *conn, const char *path, + const char *remote_path) { char *ret; + if (can_expand_path(conn)) + return do_expand_path(conn, path); + /* Handle ~ prefixed paths */ if (*path != '~') ret = xstrdup(path); @@ -1263,7 +1267,7 @@ * No need to glob here - the local shell already took care of * the expansions */ - if ((target = absolute_remote_path(targ, *remote_path)) == NULL) + if ((target = absolute_remote_path(conn, targ, *remote_path)) == NULL) cleanup_exit(255); target_is_dir = remote_is_dir(conn, target); if (targetshouldbedirectory && !target_is_dir) { @@ -1475,7 +1479,7 @@ goto out; } - if ((abs_src = absolute_remote_path(src, remote_path)) == NULL) { + if ((abs_src = absolute_remote_path(conn, src, remote_path)) == NULL) { err = -1; goto out; } @@ -1879,8 +1883,9 @@ if ((filename = basename(src)) == NULL) fatal("basename %s: %s", src, strerror(errno)); - if ((abs_src = absolute_remote_path(src, from_remote_path)) == NULL || - (target = absolute_remote_path(targ, *to_remote_path)) == NULL) + if ((abs_src = absolute_remote_path(from, src, + from_remote_path)) == NULL || + (target = absolute_remote_path(to, targ, *to_remote_path)) == NULL) cleanup_exit(255); free(from_remote_path); memset(&g, 0, sizeof(g));