mirror of git://anongit.mindrot.org/openssh.git
- 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
This commit is contained in:
parent
194454d7a8
commit
ea64721275
|
@ -25,6 +25,12 @@
|
||||||
- dtucker@cvs.openbsd.org 2013/06/04 19:12:23
|
- dtucker@cvs.openbsd.org 2013/06/04 19:12:23
|
||||||
[scp.c]
|
[scp.c]
|
||||||
use MAXPATHLEN for buffer size instead of fixed value. ok markus
|
use MAXPATHLEN for buffer size instead of fixed value. ok markus
|
||||||
|
- 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
|
||||||
|
|
||||||
20130602
|
20130602
|
||||||
- (tim) [Makefile.in] Make Solaris, UnixWare, & OpenServer linkers happy
|
- (tim) [Makefile.in] Make Solaris, UnixWare, & OpenServer linkers happy
|
||||||
|
|
16
sftp.c
16
sftp.c
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: sftp.c,v 1.145 2013/05/17 00:13:14 djm Exp $ */
|
/* $OpenBSD: sftp.c,v 1.146 2013/06/04 20:42:36 dtucker Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
|
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
|
||||||
*
|
*
|
||||||
|
@ -38,6 +38,7 @@
|
||||||
#ifdef HAVE_LIBGEN_H
|
#ifdef HAVE_LIBGEN_H
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <locale.h>
|
||||||
#ifdef USE_LIBEDIT
|
#ifdef USE_LIBEDIT
|
||||||
#include <histedit.h>
|
#include <histedit.h>
|
||||||
#else
|
#else
|
||||||
|
@ -1701,8 +1702,9 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path,
|
||||||
char *file, int remote, int lastarg, char quote, int terminated)
|
char *file, int remote, int lastarg, char quote, int terminated)
|
||||||
{
|
{
|
||||||
glob_t g;
|
glob_t g;
|
||||||
char *tmp, *tmp2, ins[3];
|
char *tmp, *tmp2, ins[8];
|
||||||
u_int i, hadglob, pwdlen, len, tmplen, filelen, cesc, isesc, isabs;
|
u_int i, hadglob, pwdlen, len, tmplen, filelen, cesc, isesc, isabs;
|
||||||
|
int clen;
|
||||||
const LineInfo *lf;
|
const LineInfo *lf;
|
||||||
|
|
||||||
/* Glob from "file" location */
|
/* Glob from "file" location */
|
||||||
|
@ -1771,10 +1773,13 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path,
|
||||||
tmp2 = tmp + filelen - cesc;
|
tmp2 = tmp + filelen - cesc;
|
||||||
len = strlen(tmp2);
|
len = strlen(tmp2);
|
||||||
/* quote argument on way out */
|
/* 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[0] = '\\';
|
||||||
ins[1] = tmp2[i];
|
memcpy(ins + 1, tmp2 + i, clen);
|
||||||
ins[2] = '\0';
|
ins[clen + 1] = '\0';
|
||||||
switch (tmp2[i]) {
|
switch (tmp2[i]) {
|
||||||
case '\'':
|
case '\'':
|
||||||
case '"':
|
case '"':
|
||||||
|
@ -2120,6 +2125,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
|
/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
|
||||||
sanitise_stdfd();
|
sanitise_stdfd();
|
||||||
|
setlocale(LC_CTYPE, "");
|
||||||
|
|
||||||
__progname = ssh_get_progname(argv[0]);
|
__progname = ssh_get_progname(argv[0]);
|
||||||
memset(&args, '\0', sizeof(args));
|
memset(&args, '\0', sizeof(args));
|
||||||
|
|
Loading…
Reference in New Issue