summaryrefslogtreecommitdiffstats
path: root/crypto/openssh/sftp-client.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2006-09-30 13:29:51 +0000
committerdes <des@FreeBSD.org>2006-09-30 13:29:51 +0000
commit2f35ce4773442329d7798ccfecd8db9dcdce89bf (patch)
treebba6f2fe7855d7b0095f9dc7720dc27bea4d1fdf /crypto/openssh/sftp-client.c
parent03ef9d989bf2619956d8c703362439e9be9257ca (diff)
downloadFreeBSD-src-2f35ce4773442329d7798ccfecd8db9dcdce89bf.zip
FreeBSD-src-2f35ce4773442329d7798ccfecd8db9dcdce89bf.tar.gz
Vendor import of OpenSSH 4.4p1.
Diffstat (limited to 'crypto/openssh/sftp-client.c')
-rw-r--r--crypto/openssh/sftp-client.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/crypto/openssh/sftp-client.c b/crypto/openssh/sftp-client.c
index 05bce33..e31b2cf 100644
--- a/crypto/openssh/sftp-client.c
+++ b/crypto/openssh/sftp-client.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: sftp-client.c,v 1.74 2006/08/03 03:34:42 deraadt Exp $ */
/*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
*
@@ -20,17 +21,32 @@
/* XXX: copy between two remote sites */
#include "includes.h"
-RCSID("$OpenBSD: sftp-client.c,v 1.58 2006/01/02 01:20:31 djm Exp $");
+#include <sys/types.h>
+#include <sys/param.h>
#include "openbsd-compat/sys-queue.h"
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#include <sys/uio.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
-#include "buffer.h"
-#include "bufaux.h"
-#include "getput.h"
#include "xmalloc.h"
+#include "buffer.h"
#include "log.h"
#include "atomicio.h"
#include "progressmeter.h"
+#include "misc.h"
#include "sftp.h"
#include "sftp-common.h"
@@ -39,7 +55,7 @@ RCSID("$OpenBSD: sftp-client.c,v 1.58 2006/01/02 01:20:31 djm Exp $");
extern volatile sig_atomic_t interrupted;
extern int showprogress;
-/* Minimum amount of data to read at at time */
+/* Minimum amount of data to read at a time */
#define MIN_READ_SIZE 512
struct sftp_conn {
@@ -55,16 +71,19 @@ static void
send_msg(int fd, Buffer *m)
{
u_char mlen[4];
+ struct iovec iov[2];
if (buffer_len(m) > SFTP_MAX_MSG_LENGTH)
fatal("Outbound message too long %u", buffer_len(m));
/* Send length first */
- PUT_32BIT(mlen, buffer_len(m));
- if (atomicio(vwrite, fd, mlen, sizeof(mlen)) != sizeof(mlen))
- fatal("Couldn't send packet: %s", strerror(errno));
+ put_u32(mlen, buffer_len(m));
+ iov[0].iov_base = mlen;
+ iov[0].iov_len = sizeof(mlen);
+ iov[1].iov_base = buffer_ptr(m);
+ iov[1].iov_len = buffer_len(m);
- if (atomicio(vwrite, fd, buffer_ptr(m), buffer_len(m)) != buffer_len(m))
+ if (atomiciov(writev, fd, iov, 2) != buffer_len(m) + sizeof(mlen))
fatal("Couldn't send packet: %s", strerror(errno));
buffer_clear(m);
@@ -388,8 +407,7 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int printflag,
printf("%s\n", longname);
if (dir) {
- *dir = xrealloc(*dir, sizeof(**dir) *
- (ents + 2));
+ *dir = xrealloc(*dir, ents + 2, sizeof(**dir));
(*dir)[ents] = xmalloc(sizeof(***dir));
(*dir)[ents]->filename = xstrdup(filename);
(*dir)[ents]->longname = xstrdup(longname);
OpenPOWER on IntegriCloud