diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | sftp.c | 9 |
2 files changed, 10 insertions, 3 deletions
@@ -10,6 +10,10 @@ | |||
10 | [sftp.c] | 10 | [sftp.c] |
11 | Add bounds check on sftp tab-completion. Part of a patch from from | 11 | Add bounds check on sftp tab-completion. Part of a patch from from |
12 | Jean-Marc Robert via tech@, ok djm | 12 | Jean-Marc Robert via tech@, ok djm |
13 | - dtucker@cvs.openbsd.org 2012/09/21 10:53:07 | ||
14 | [sftp.c] | ||
15 | Fix improper handling of absolute paths when PWD is part of the completed | ||
16 | path. Patch from Jean-Marc Robert via tech@, ok djm. | ||
13 | 17 | ||
14 | 20120917 | 18 | 20120917 |
15 | - (dtucker) OpenBSD CVS Sync | 19 | - (dtucker) OpenBSD CVS Sync |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sftp.c,v 1.138 2012/09/18 10:36:12 dtucker Exp $ */ | 1 | /* $OpenBSD: sftp.c,v 1.139 2012/09/21 10:53:07 dtucker Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> | 3 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> |
4 | * | 4 | * |
@@ -1699,7 +1699,7 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path, | |||
1699 | { | 1699 | { |
1700 | glob_t g; | 1700 | glob_t g; |
1701 | char *tmp, *tmp2, ins[3]; | 1701 | char *tmp, *tmp2, ins[3]; |
1702 | u_int i, hadglob, pwdlen, len, tmplen, filelen; | 1702 | u_int i, hadglob, pwdlen, len, tmplen, filelen, isabs; |
1703 | const LineInfo *lf; | 1703 | const LineInfo *lf; |
1704 | 1704 | ||
1705 | /* Glob from "file" location */ | 1705 | /* Glob from "file" location */ |
@@ -1708,6 +1708,9 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path, | |||
1708 | else | 1708 | else |
1709 | xasprintf(&tmp, "%s*", file); | 1709 | xasprintf(&tmp, "%s*", file); |
1710 | 1710 | ||
1711 | /* Check if the path is absolute. */ | ||
1712 | isabs = tmp[0] == '/'; | ||
1713 | |||
1711 | memset(&g, 0, sizeof(g)); | 1714 | memset(&g, 0, sizeof(g)); |
1712 | if (remote != LOCAL) { | 1715 | if (remote != LOCAL) { |
1713 | tmp = make_absolute(tmp, remote_path); | 1716 | tmp = make_absolute(tmp, remote_path); |
@@ -1742,7 +1745,7 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path, | |||
1742 | goto out; | 1745 | goto out; |
1743 | 1746 | ||
1744 | tmp2 = complete_ambiguous(file, g.gl_pathv, g.gl_matchc); | 1747 | tmp2 = complete_ambiguous(file, g.gl_pathv, g.gl_matchc); |
1745 | tmp = path_strip(tmp2, remote_path); | 1748 | tmp = path_strip(tmp2, isabs ? NULL : remote_path); |
1746 | xfree(tmp2); | 1749 | xfree(tmp2); |
1747 | 1750 | ||
1748 | if (tmp == NULL) | 1751 | if (tmp == NULL) |