diff options
author | Darren Tucker <dtucker@cvs.openbsd.org> | 2012-09-21 10:53:08 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@cvs.openbsd.org> | 2012-09-21 10:53:08 +0000 |
commit | c0da7ef07c685f740560f89a87c86d4d334bae5c (patch) | |
tree | 2f41307575c96e23084c1f5bdeb5839719f0778e /usr.bin | |
parent | f4052dcf6a490e95d9ba80644c70f44b14b072c7 (diff) |
Fix improper handling of absolute paths when PWD is part of the completed
path. Patch from Jean-Marc Robert via tech@, ok djm.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/sftp.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/ssh/sftp.c b/usr.bin/ssh/sftp.c index b6db5d80fa9..8f370081538 100644 --- a/usr.bin/ssh/sftp.c +++ b/usr.bin/ssh/sftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp.c,v 1.138 2012/09/18 10:36:12 dtucker Exp $ */ +/* $OpenBSD: sftp.c,v 1.139 2012/09/21 10:53:07 dtucker Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> * @@ -1675,7 +1675,7 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path, { glob_t g; char *tmp, *tmp2, ins[3]; - u_int i, hadglob, pwdlen, len, tmplen, filelen; + u_int i, hadglob, pwdlen, len, tmplen, filelen, isabs; const LineInfo *lf; /* Glob from "file" location */ @@ -1684,6 +1684,9 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path, else xasprintf(&tmp, "%s*", file); + /* Check if the path is absolute. */ + isabs = tmp[0] == '/'; + memset(&g, 0, sizeof(g)); if (remote != LOCAL) { tmp = make_absolute(tmp, remote_path); @@ -1718,7 +1721,7 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path, goto out; tmp2 = complete_ambiguous(file, g.gl_pathv, g.gl_matchc); - tmp = path_strip(tmp2, remote_path); + tmp = path_strip(tmp2, isabs ? NULL : remote_path); xfree(tmp2); if (tmp == NULL) |