diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | sftp.c | 20 |
2 files changed, 20 insertions, 4 deletions
@@ -14,6 +14,10 @@ | |||
14 | [sftp.c] | 14 | [sftp.c] |
15 | Fix improper handling of absolute paths when PWD is part of the completed | 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. | 16 | path. Patch from Jean-Marc Robert via tech@, ok djm. |
17 | - dtucker@cvs.openbsd.org 2012/09/21 10:55:04 | ||
18 | [sftp.c] | ||
19 | Fix handling of filenames containing escaped globbing characters and | ||
20 | escape "#" and "*". Patch from Jean-Marc Robert via tech@, ok djm. | ||
17 | 21 | ||
18 | 20120917 | 22 | 20120917 |
19 | - (dtucker) OpenBSD CVS Sync | 23 | - (dtucker) OpenBSD CVS Sync |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sftp.c,v 1.139 2012/09/21 10:53:07 dtucker Exp $ */ | 1 | /* $OpenBSD: sftp.c,v 1.140 2012/09/21 10:55:04 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, isabs; | 1702 | u_int i, hadglob, pwdlen, len, tmplen, filelen, cesc, isesc, isabs; |
1703 | const LineInfo *lf; | 1703 | const LineInfo *lf; |
1704 | 1704 | ||
1705 | /* Glob from "file" location */ | 1705 | /* Glob from "file" location */ |
@@ -1754,8 +1754,18 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path, | |||
1754 | tmplen = strlen(tmp); | 1754 | tmplen = strlen(tmp); |
1755 | filelen = strlen(file); | 1755 | filelen = strlen(file); |
1756 | 1756 | ||
1757 | if (tmplen > filelen) { | 1757 | /* Count the number of escaped characters in the input string. */ |
1758 | tmp2 = tmp + filelen; | 1758 | cesc = isesc = 0; |
1759 | for (i = 0; i < filelen; i++) { | ||
1760 | if (!isesc && file[i] == '\\' && i + 1 < filelen){ | ||
1761 | isesc = 1; | ||
1762 | cesc++; | ||
1763 | } else | ||
1764 | isesc = 0; | ||
1765 | } | ||
1766 | |||
1767 | if (tmplen > (filelen - cesc)) { | ||
1768 | tmp2 = tmp + filelen - cesc; | ||
1759 | len = strlen(tmp2); | 1769 | len = strlen(tmp2); |
1760 | /* quote argument on way out */ | 1770 | /* quote argument on way out */ |
1761 | for (i = 0; i < len; i++) { | 1771 | for (i = 0; i < len; i++) { |
@@ -1769,6 +1779,8 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path, | |||
1769 | case '\t': | 1779 | case '\t': |
1770 | case '[': | 1780 | case '[': |
1771 | case ' ': | 1781 | case ' ': |
1782 | case '#': | ||
1783 | case '*': | ||
1772 | if (quote == '\0' || tmp2[i] == quote) { | 1784 | if (quote == '\0' || tmp2[i] == quote) { |
1773 | if (el_insertstr(el, ins) == -1) | 1785 | if (el_insertstr(el, ins) == -1) |
1774 | fatal("el_insertstr " | 1786 | fatal("el_insertstr " |