=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/sftp.c,v retrieving revision 1.75.2.2 retrieving revision 1.76 diff -u -r1.75.2.2 -r1.76 --- src/usr.bin/ssh/sftp.c 2006/11/08 00:17:14 1.75.2.2 +++ src/usr.bin/ssh/sftp.c 2006/03/19 02:22:56 1.76 @@ -1,4 +1,3 @@ -/* $OpenBSD: sftp.c,v 1.75.2.2 2006/11/08 00:17:14 brad Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller * @@ -15,31 +14,26 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#include "includes.h" +RCSID("$OpenBSD: sftp.c,v 1.76 2006/03/19 02:22:56 djm Exp $"); + #include +#include #include #include -#include -#include -#include #include #include #include #include -#include -#include -#include -#include -#include +#include "buffer.h" #include "xmalloc.h" #include "log.h" #include "pathnames.h" #include "misc.h" #include "sftp.h" -#include "buffer.h" #include "sftp-common.h" #include "sftp-client.h" @@ -242,7 +236,7 @@ if (errno != EINTR) fatal("Couldn't wait for child: %s", strerror(errno)); if (!WIFEXITED(status)) - error("Shell exited abnormally"); + error("Shell exited abormally"); else if (WEXITSTATUS(status)) error("Shell exited with status %d", WEXITSTATUS(status)); } @@ -481,7 +475,7 @@ if (stat(path, &sb) == -1) return(0); - return(S_ISDIR(sb.st_mode)); + return(sb.st_mode & S_IFDIR); } static int @@ -505,7 +499,7 @@ return(0); if (!(a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS)) return(0); - return(S_ISDIR(a->perm)); + return(a->perm & S_IFDIR); } static int @@ -545,7 +539,6 @@ if (g.gl_matchc == 1 && dst) { /* If directory specified, append filename */ - xfree(tmp); if (is_dir(dst)) { if (infer_path(g.gl_pathv[0], &tmp)) { err = 1; @@ -570,6 +563,8 @@ out: xfree(abs_src); + if (abs_dst) + xfree(abs_dst); globfree(&g); return(err); } @@ -965,7 +960,6 @@ case I_CHOWN: case I_CHGRP: /* Get numeric arg (mandatory) */ - errno = 0; l = strtol(cp, &cp2, base); if (cp2 == cp || ((l == LONG_MIN || l == LONG_MAX) && errno == ERANGE) || l < 0) { @@ -1367,12 +1361,23 @@ { int c_in, c_out; +#ifdef USE_PIPES + int pin[2], pout[2]; + + if ((pipe(pin) == -1) || (pipe(pout) == -1)) + fatal("pipe: %s", strerror(errno)); + *in = pin[0]; + *out = pout[1]; + c_in = pout[0]; + c_out = pin[1]; +#else /* USE_PIPES */ int inout[2]; if (socketpair(AF_UNIX, SOCK_STREAM, 0, inout) == -1) fatal("socketpair: %s", strerror(errno)); *in = *out = inout[0]; c_in = c_out = inout[1]; +#endif /* USE_PIPES */ if ((sshpid = fork()) == -1) fatal("fork: %s", strerror(errno)); @@ -1439,7 +1444,7 @@ memset(&args, '\0', sizeof(args)); args.list = NULL; - addargs(&args, "%s", ssh_program); + addargs(&args, ssh_program); addargs(&args, "-oForwardX11 no"); addargs(&args, "-oForwardAgent no"); addargs(&args, "-oPermitLocalCommand no");