diff --git a/openssh-6.2p2-sftp-multibyte.patch b/openssh-6.2p2-sftp-multibyte.patch new file mode 100644 index 0000000..2f9b423 --- /dev/null +++ b/openssh-6.2p2-sftp-multibyte.patch @@ -0,0 +1,64 @@ +diff --git a/ChangeLog b/ChangeLog +index f5e2df0..74a03f8 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,3 +1,11 @@ ++20130605 ++ - dtucker@cvs.openbsd.org 2013/06/04 20:42:36 ++ [sftp.c] ++ Make sftp's libedit interface marginally multibyte aware by building up ++ the quoted string by character instead of by byte. Prevents failures ++ when linked against a libedit built with wide character support (bz#1990). ++ "looks ok" djm ++ + 20130516 + - (djm) [contrib/ssh-copy-id] Fix bug that could cause "rm *" to be + executed if mktemp failed; bz#2105 ok dtucker@ +diff --git a/sftp.c b/sftp.c +index 25c35fa..c9a9919 100644 +--- a/sftp.c ++++ b/sftp.c +@@ -38,6 +38,7 @@ + #ifdef HAVE_LIBGEN_H + #include + #endif ++#include + #ifdef USE_LIBEDIT + #include + #else +@@ -1694,8 +1695,9 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path, + char *file, int remote, int lastarg, char quote, int terminated) + { + glob_t g; +- char *tmp, *tmp2, ins[3]; ++ char *tmp, *tmp2, ins[8]; + u_int i, hadglob, pwdlen, len, tmplen, filelen, cesc, isesc, isabs; ++ int clen; + const LineInfo *lf; + + /* Glob from "file" location */ +@@ -1764,10 +1766,13 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path, + tmp2 = tmp + filelen - cesc; + len = strlen(tmp2); + /* quote argument on way out */ +- for (i = 0; i < len; i++) { ++ for (i = 0; i < len; i += clen) { ++ if ((clen = mblen(tmp2 + i, len - i)) < 0 || ++ (size_t)clen > sizeof(ins) - 2) ++ fatal("invalid multibyte character"); + ins[0] = '\\'; +- ins[1] = tmp2[i]; +- ins[2] = '\0'; ++ memcpy(ins + 1, tmp2 + i, clen); ++ ins[clen + 1] = '\0'; + switch (tmp2[i]) { + case '\'': + case '"': +@@ -2112,6 +2117,7 @@ main(int argc, char **argv) + + /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ + sanitise_stdfd(); ++ setlocale(LC_CTYPE, ""); + + __progname = ssh_get_progname(argv[0]); + memset(&args, '\0', sizeof(args)); diff --git a/openssh.spec b/openssh.spec index 67be623..ded8442 100644 --- a/openssh.spec +++ b/openssh.spec @@ -182,6 +182,8 @@ Patch901: openssh-6.2p1-kuserok.patch Patch905: openssh-6.2p1-modpipe-cflags.patch # add latest config.{sub,guess} to support aarch64 (#926284) Patch907: openssh-6.2p1-aarch64.patch +# make sftp's libedit interface marginally multibyte aware (#841771) +Patch908: openssh-6.2p2-sftp-multibyte.patch License: BSD @@ -402,6 +404,7 @@ popd %patch901 -p1 -b .kuserok %patch905 -p1 -b .modpipe-cflags %patch907 -p1 -b .aarch64 +%patch908 -p1 -b .sftp-multibyte %if 0 # Nothing here yet