summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2006-04-23 04:06:35 +0200
committerDamien Miller <djm@mindrot.org>2006-04-23 04:06:35 +0200
commit58ca98bfe12b65f4d445dc05b422f672c51caa4b (patch)
treece42acb4be05592c9aef3c0a1d8c396a28095f46
parent - djm@cvs.openbsd.org 2006/04/16 00:52:55 (diff)
downloadopenssh-58ca98bfe12b65f4d445dc05b422f672c51caa4b.tar.xz
openssh-58ca98bfe12b65f4d445dc05b422f672c51caa4b.zip
- djm@cvs.openbsd.org 2006/04/16 00:54:10
[sftp-client.c] avoid making a tiny 4-byte write to send the packet length of sftp commands, which would result in a separate tiny packet on the wire by using atomiciov(writev, ...) to write the length and the command in one pass; ok deraadt@
-rw-r--r--ChangeLog8
-rw-r--r--sftp-client.c13
2 files changed, 15 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 812312bd9..0a597a4fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,6 +31,12 @@
introduce atomiciov() function that wraps readv/writev to retry
interrupted transfers like atomicio() does for read/write;
feedback deraadt@ dtucker@ stevesk@ ok deraadt@
+ - djm@cvs.openbsd.org 2006/04/16 00:54:10
+ [sftp-client.c]
+ avoid making a tiny 4-byte write to send the packet length of sftp
+ commands, which would result in a separate tiny packet on the wire by
+ using atomiciov(writev, ...) to write the length and the command in one
+ pass; ok deraadt@
20060421
- (djm) [Makefile.in configure.ac session.c sshpty.c]
@@ -4542,4 +4548,4 @@
- (djm) Trim deprecated options from INSTALL. Mention UsePAM
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
-$Id: ChangeLog,v 1.4308 2006/04/23 02:06:20 djm Exp $
+$Id: ChangeLog,v 1.4309 2006/04/23 02:06:35 djm Exp $
diff --git a/sftp-client.c b/sftp-client.c
index c71c66f33..8778439b9 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp-client.c,v 1.64 2006/03/30 09:58:16 djm Exp $ */
+/* $OpenBSD: sftp-client.c,v 1.65 2006/04/16 00:54:10 djm Exp $ */
/*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
*
@@ -61,16 +61,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_u32(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))
+ 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);