summaryrefslogtreecommitdiff
path: root/atomicio.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2007-12-24 10:29:57 +0000
committerColin Watson <cjwatson@debian.org>2007-12-24 10:29:57 +0000
commitc3e531b12b2335b7fa5a6bcc9a309d3c523ff64b (patch)
treeb72c0867348e7e7914d64af6fc5e25c728922e03 /atomicio.c
parent6b222fdf3cb54c11a446df38e027fe7acf2220cb (diff)
parent70847d299887abb96f8703ca99db6d817b78960e (diff)
* New upstream release (closes: #453367).
- CVE-2007-4752: Prevent ssh(1) from using a trusted X11 cookie if creation of an untrusted cookie fails; found and fixed by Jan Pechanec (closes: #444738). - sshd(8) in new installations defaults to SSH Protocol 2 only. Existing installations are unchanged. - The SSH channel window size has been increased, and both ssh(1) sshd(8) now send window updates more aggressively. These improves performance on high-BDP (Bandwidth Delay Product) networks. - ssh(1) and sshd(8) now preserve MAC contexts between packets, which saves 2 hash calls per packet and results in 12-16% speedup for arcfour256/hmac-md5. - A new MAC algorithm has been added, UMAC-64 (RFC4418) as "umac-64@openssh.com". UMAC-64 has been measured to be approximately 20% faster than HMAC-MD5. - Failure to establish a ssh(1) TunnelForward is now treated as a fatal error when the ExitOnForwardFailure option is set. - ssh(1) returns a sensible exit status if the control master goes away without passing the full exit status. - When using a ProxyCommand in ssh(1), set the outgoing hostname with gethostname(2), allowing hostbased authentication to work. - Make scp(1) skip FIFOs rather than hanging (closes: #246774). - Encode non-printing characters in scp(1) filenames. These could cause copies to be aborted with a "protocol error". - Handle SIGINT in sshd(8) privilege separation child process to ensure that wtmp and lastlog records are correctly updated. - Report GSSAPI mechanism in errors, for libraries that support multiple mechanisms. - Improve documentation for ssh-add(1)'s -d option. - Rearrange and tidy GSSAPI code, removing server-only code being linked into the client. - Delay execution of ssh(1)'s LocalCommand until after all forwardings have been established. - In scp(1), do not truncate non-regular files. - Improve exit message from ControlMaster clients. - Prevent sftp-server(8) from reading until it runs out of buffer space, whereupon it would exit with a fatal error (closes: #365541). - pam_end() was not being called if authentication failed (closes: #405041). - Manual page datestamps updated (closes: #433181).
Diffstat (limited to 'atomicio.c')
-rw-r--r--atomicio.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/atomicio.c b/atomicio.c
index f651a292c..f32ff85ba 100644
--- a/atomicio.c
+++ b/atomicio.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: atomicio.c,v 1.23 2006/08/03 03:34:41 deraadt Exp $ */ 1/* $OpenBSD: atomicio.c,v 1.25 2007/06/25 12:02:27 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2006 Damien Miller. All rights reserved. 3 * Copyright (c) 2006 Damien Miller. All rights reserved.
4 * Copyright (c) 2005 Anil Madhavapeddy. All rights reserved. 4 * Copyright (c) 2005 Anil Madhavapeddy. All rights reserved.
@@ -32,7 +32,11 @@
32#include <sys/uio.h> 32#include <sys/uio.h>
33 33
34#include <errno.h> 34#include <errno.h>
35#ifdef HAVE_POLL_H
36#include <poll.h>
37#endif
35#include <string.h> 38#include <string.h>
39#include <unistd.h>
36 40
37#include "atomicio.h" 41#include "atomicio.h"
38 42
@@ -45,17 +49,24 @@ atomicio(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n)
45 char *s = _s; 49 char *s = _s;
46 size_t pos = 0; 50 size_t pos = 0;
47 ssize_t res; 51 ssize_t res;
52 struct pollfd pfd;
48 53
54 pfd.fd = fd;
55 pfd.events = f == read ? POLLIN : POLLOUT;
49 while (n > pos) { 56 while (n > pos) {
50 res = (f) (fd, s + pos, n - pos); 57 res = (f) (fd, s + pos, n - pos);
51 switch (res) { 58 switch (res) {
52 case -1: 59 case -1:
53#ifdef EWOULDBLOCK 60#ifdef EWOULDBLOCK
54 if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) 61 if (errno == EINTR || errno == EWOULDBLOCK)
55#else 62#else
56 if (errno == EINTR || errno == EAGAIN) 63 if (errno == EINTR)
57#endif 64#endif
58 continue; 65 continue;
66 if (errno == EAGAIN) {
67 (void)poll(&pfd, 1, -1);
68 continue;
69 }
59 return 0; 70 return 0;
60 case 0: 71 case 0:
61 errno = EPIPE; 72 errno = EPIPE;
@@ -77,6 +88,7 @@ atomiciov(ssize_t (*f) (int, const struct iovec *, int), int fd,
77 size_t pos = 0, rem; 88 size_t pos = 0, rem;
78 ssize_t res; 89 ssize_t res;
79 struct iovec iov_array[IOV_MAX], *iov = iov_array; 90 struct iovec iov_array[IOV_MAX], *iov = iov_array;
91 struct pollfd pfd;
80 92
81 if (iovcnt > IOV_MAX) { 93 if (iovcnt > IOV_MAX) {
82 errno = EINVAL; 94 errno = EINVAL;
@@ -85,12 +97,22 @@ atomiciov(ssize_t (*f) (int, const struct iovec *, int), int fd,
85 /* Make a copy of the iov array because we may modify it below */ 97 /* Make a copy of the iov array because we may modify it below */
86 memcpy(iov, _iov, iovcnt * sizeof(*_iov)); 98 memcpy(iov, _iov, iovcnt * sizeof(*_iov));
87 99
100 pfd.fd = fd;
101 pfd.events = f == readv ? POLLIN : POLLOUT;
88 for (; iovcnt > 0 && iov[0].iov_len > 0;) { 102 for (; iovcnt > 0 && iov[0].iov_len > 0;) {
89 res = (f) (fd, iov, iovcnt); 103 res = (f) (fd, iov, iovcnt);
90 switch (res) { 104 switch (res) {
91 case -1: 105 case -1:
92 if (errno == EINTR || errno == EAGAIN) 106#ifdef EWOULDBLOCK
107 if (errno == EINTR || errno == EWOULDBLOCK)
108#else
109 if (errno == EINTR)
110#endif
93 continue; 111 continue;
112 if (errno == EAGAIN) {
113 (void)poll(&pfd, 1, -1);
114 continue;
115 }
94 return 0; 116 return 0;
95 case 0: 117 case 0:
96 errno = EPIPE; 118 errno = EPIPE;