|
Petr Lautrbach |
2ee681 |
diff --git a/ChangeLog b/ChangeLog
|
|
Petr Lautrbach |
2ee681 |
index f5e2df0..74a03f8 100644
|
|
Petr Lautrbach |
2ee681 |
--- a/ChangeLog
|
|
Petr Lautrbach |
2ee681 |
+++ b/ChangeLog
|
|
Petr Lautrbach |
2ee681 |
@@ -1,3 +1,11 @@
|
|
Petr Lautrbach |
2ee681 |
+20130605
|
|
Petr Lautrbach |
2ee681 |
+ - dtucker@cvs.openbsd.org 2013/06/04 20:42:36
|
|
Petr Lautrbach |
2ee681 |
+ [sftp.c]
|
|
Petr Lautrbach |
2ee681 |
+ Make sftp's libedit interface marginally multibyte aware by building up
|
|
Petr Lautrbach |
2ee681 |
+ the quoted string by character instead of by byte. Prevents failures
|
|
Petr Lautrbach |
2ee681 |
+ when linked against a libedit built with wide character support (bz#1990).
|
|
Petr Lautrbach |
2ee681 |
+ "looks ok" djm
|
|
Petr Lautrbach |
2ee681 |
+
|
|
Petr Lautrbach |
2ee681 |
20130516
|
|
Petr Lautrbach |
2ee681 |
- (djm) [contrib/ssh-copy-id] Fix bug that could cause "rm *" to be
|
|
Petr Lautrbach |
2ee681 |
executed if mktemp failed; bz#2105 ok dtucker@
|
|
Petr Lautrbach |
2ee681 |
diff --git a/sftp.c b/sftp.c
|
|
Petr Lautrbach |
2ee681 |
index 25c35fa..c9a9919 100644
|
|
Petr Lautrbach |
2ee681 |
--- a/sftp.c
|
|
Petr Lautrbach |
2ee681 |
+++ b/sftp.c
|
|
Petr Lautrbach |
2ee681 |
@@ -38,6 +38,7 @@
|
|
Petr Lautrbach |
2ee681 |
#ifdef HAVE_LIBGEN_H
|
|
Petr Lautrbach |
2ee681 |
#include <libgen.h>
|
|
Petr Lautrbach |
2ee681 |
#endif
|
|
Petr Lautrbach |
2ee681 |
+#include <locale.h>
|
|
Petr Lautrbach |
2ee681 |
#ifdef USE_LIBEDIT
|
|
Petr Lautrbach |
2ee681 |
#include <histedit.h>
|
|
Petr Lautrbach |
2ee681 |
#else
|
|
Petr Lautrbach |
2ee681 |
@@ -1694,8 +1695,9 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path,
|
|
Petr Lautrbach |
2ee681 |
char *file, int remote, int lastarg, char quote, int terminated)
|
|
Petr Lautrbach |
2ee681 |
{
|
|
Petr Lautrbach |
2ee681 |
glob_t g;
|
|
Petr Lautrbach |
2ee681 |
- char *tmp, *tmp2, ins[3];
|
|
Petr Lautrbach |
2ee681 |
+ char *tmp, *tmp2, ins[8];
|
|
Petr Lautrbach |
2ee681 |
u_int i, hadglob, pwdlen, len, tmplen, filelen, cesc, isesc, isabs;
|
|
Petr Lautrbach |
2ee681 |
+ int clen;
|
|
Petr Lautrbach |
2ee681 |
const LineInfo *lf;
|
|
Petr Lautrbach |
2ee681 |
|
|
Petr Lautrbach |
2ee681 |
/* Glob from "file" location */
|
|
Petr Lautrbach |
2ee681 |
@@ -1764,10 +1766,13 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path,
|
|
Petr Lautrbach |
2ee681 |
tmp2 = tmp + filelen - cesc;
|
|
Petr Lautrbach |
2ee681 |
len = strlen(tmp2);
|
|
Petr Lautrbach |
2ee681 |
/* quote argument on way out */
|
|
Petr Lautrbach |
2ee681 |
- for (i = 0; i < len; i++) {
|
|
Petr Lautrbach |
2ee681 |
+ for (i = 0; i < len; i += clen) {
|
|
Petr Lautrbach |
2ee681 |
+ if ((clen = mblen(tmp2 + i, len - i)) < 0 ||
|
|
Petr Lautrbach |
2ee681 |
+ (size_t)clen > sizeof(ins) - 2)
|
|
Petr Lautrbach |
2ee681 |
+ fatal("invalid multibyte character");
|
|
Petr Lautrbach |
2ee681 |
ins[0] = '\\';
|
|
Petr Lautrbach |
2ee681 |
- ins[1] = tmp2[i];
|
|
Petr Lautrbach |
2ee681 |
- ins[2] = '\0';
|
|
Petr Lautrbach |
2ee681 |
+ memcpy(ins + 1, tmp2 + i, clen);
|
|
Petr Lautrbach |
2ee681 |
+ ins[clen + 1] = '\0';
|
|
Petr Lautrbach |
2ee681 |
switch (tmp2[i]) {
|
|
Petr Lautrbach |
2ee681 |
case '\'':
|
|
Petr Lautrbach |
2ee681 |
case '"':
|
|
Petr Lautrbach |
2ee681 |
@@ -2112,6 +2117,7 @@ main(int argc, char **argv)
|
|
Petr Lautrbach |
2ee681 |
|
|
Petr Lautrbach |
2ee681 |
/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
|
|
Petr Lautrbach |
2ee681 |
sanitise_stdfd();
|
|
Petr Lautrbach |
2ee681 |
+ setlocale(LC_CTYPE, "");
|
|
Petr Lautrbach |
2ee681 |
|
|
Petr Lautrbach |
2ee681 |
__progname = ssh_get_progname(argv[0]);
|
|
Petr Lautrbach |
2ee681 |
memset(&args, '\0', sizeof(args));
|