]> andersk Git - openssh.git/blobdiff - sftp-client.c
- stevesk@cvs.openbsd.org 2006/07/22 19:08:54
[openssh.git] / sftp-client.c
index 9dfdf5ad54aef0d044815122794c6f052e4045bc..5ba4f0a9f44f8d978bcb4625fd8aeae7780f5f88 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenBSD: sftp-client.c,v 1.68 2006/07/17 01:31:09 stevesk Exp $ */
 /*
  * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
  *
 /* XXX: copy between two remote sites */
 
 #include "includes.h"
-RCSID("$OpenBSD: sftp-client.c,v 1.59 2006/02/15 05:08:24 david Exp $");
+
+#include <sys/types.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <unistd.h>
 
 #include "openbsd-compat/sys-queue.h"
 
 #include "buffer.h"
 #include "bufaux.h"
-#include "getput.h"
 #include "xmalloc.h"
 #include "log.h"
 #include "atomicio.h"
 #include "progressmeter.h"
+#include "misc.h"
 
 #include "sftp.h"
 #include "sftp-common.h"
@@ -55,16 +65,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));
-
-       if (atomicio(vwrite, fd, buffer_ptr(m), buffer_len(m)) != buffer_len(m))
+       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 (atomiciov(writev, fd, iov, 2) != buffer_len(m) + sizeof(mlen))
                fatal("Couldn't send packet: %s", strerror(errno));
 
        buffer_clear(m);
@@ -388,8 +401,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);
This page took 0.046021 seconds and 4 git commands to generate.