summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordtucker <dtucker>2003-07-03 03:46:56 +0000
committerdtucker <dtucker>2003-07-03 03:46:56 +0000
commit9f1044478c91186c47c443ec202d20e5edf8ae3f (patch)
tree3f766d95051ece05391dd3adad4f19f148ddc61f
parent3ff59add707691893213388a591370ef930b6a96 (diff)
downloadopenssh-9f1044478c91186c47c443ec202d20e5edf8ae3f.tar.gz
- deraadt@cvs.openbsd.org 2003/06/28 16:23:06
[atomicio.c atomicio.h authfd.c clientloop.c monitor_wrap.c msg.c progressmeter.c scp.c sftp-client.c ssh-keyscan.c ssh.h sshconnect.c sshd.c] deal with typing of write vs read in atomicio
-rw-r--r--ChangeLog7
-rw-r--r--atomicio.c4
-rw-r--r--atomicio.h8
-rw-r--r--authfd.c6
-rw-r--r--clientloop.c6
-rw-r--r--monitor_wrap.c6
-rw-r--r--msg.c6
-rw-r--r--progressmeter.c6
-rw-r--r--scp.c36
-rw-r--r--sftp-client.c8
-rw-r--r--ssh-keyscan.c4
-rw-r--r--ssh.h3
-rw-r--r--sshconnect.c4
-rw-r--r--sshd.c8
14 files changed, 60 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index 13098998..8fdfce19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,11 @@
[sshd.c]
report pidfile creation errors, based on patch from Roumen Petrov;
ok markus@
+ - deraadt@cvs.openbsd.org 2003/06/28 16:23:06
+ [atomicio.c atomicio.h authfd.c clientloop.c monitor_wrap.c msg.c
+ progressmeter.c scp.c sftp-client.c ssh-keyscan.c ssh.h sshconnect.c
+ sshd.c]
+ deal with typing of write vs read in atomicio
20030630
- (djm) Search for support functions necessary to build our
@@ -624,4 +629,4 @@
- Fix sshd BindAddress and -b options for systems using fake-getaddrinfo.
Report from murple@murple.net, diagnosis from dtucker@zip.com.au
-$Id: ChangeLog,v 1.2836 2003/07/03 03:40:44 dtucker Exp $
+$Id: ChangeLog,v 1.2837 2003/07/03 03:46:56 dtucker Exp $
diff --git a/atomicio.c b/atomicio.c
index 47161eb3..dfc1553c 100644
--- a/atomicio.c
+++ b/atomicio.c
@@ -24,7 +24,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: atomicio.c,v 1.10 2001/05/08 22:48:07 markus Exp $");
+RCSID("$OpenBSD: atomicio.c,v 1.11 2003/06/28 16:23:06 deraadt Exp $");
#include "atomicio.h"
@@ -33,7 +33,7 @@ RCSID("$OpenBSD: atomicio.c,v 1.10 2001/05/08 22:48:07 markus Exp $");
*/
ssize_t
atomicio(f, fd, _s, n)
- ssize_t (*f) ();
+ ssize_t (*f) (int, void *, size_t);
int fd;
void *_s;
size_t n;
diff --git a/atomicio.h b/atomicio.h
index e569d38c..5c0f392e 100644
--- a/atomicio.h
+++ b/atomicio.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: atomicio.h,v 1.4 2001/06/26 06:32:46 itojun Exp $ */
+/* $OpenBSD: atomicio.h,v 1.5 2003/06/28 16:23:06 deraadt Exp $ */
/*
* Copyright (c) 1995,1999 Theo de Raadt. All rights reserved.
@@ -26,6 +26,8 @@
*/
/*
- * Ensure all of data on socket comes through. f==read || f==write
+ * Ensure all of data on socket comes through. f==read || f==vwrite
*/
-ssize_t atomicio(ssize_t (*)(), int, void *, size_t);
+ssize_t atomicio(ssize_t (*)(int, void *, size_t), int, void *, size_t);
+
+#define vwrite (ssize_t (*)(int, void *, size_t))write
diff --git a/authfd.c b/authfd.c
index 368544b1..c78db6d9 100644
--- a/authfd.c
+++ b/authfd.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: authfd.c,v 1.60 2003/06/11 11:18:38 djm Exp $");
+RCSID("$OpenBSD: authfd.c,v 1.61 2003/06/28 16:23:06 deraadt Exp $");
#include <openssl/evp.h>
@@ -122,8 +122,8 @@ ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply
PUT_32BIT(buf, len);
/* Send the length and then the packet to the agent. */
- if (atomicio(write, auth->fd, buf, 4) != 4 ||
- atomicio(write, auth->fd, buffer_ptr(request),
+ if (atomicio(vwrite, auth->fd, buf, 4) != 4 ||
+ atomicio(vwrite, auth->fd, buffer_ptr(request),
buffer_len(request)) != buffer_len(request)) {
error("Error writing to authentication socket.");
return 0;
diff --git a/clientloop.c b/clientloop.c
index 1c1acf48..d8def78b 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -59,7 +59,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: clientloop.c,v 1.111 2003/05/14 22:24:42 markus Exp $");
+RCSID("$OpenBSD: clientloop.c,v 1.112 2003/06/28 16:23:06 deraadt Exp $");
#include "ssh.h"
#include "ssh1.h"
@@ -395,9 +395,9 @@ client_suspend_self(Buffer *bin, Buffer *bout, Buffer *berr)
/* Flush stdout and stderr buffers. */
if (buffer_len(bout) > 0)
- atomicio(write, fileno(stdout), buffer_ptr(bout), buffer_len(bout));
+ atomicio(vwrite, fileno(stdout), buffer_ptr(bout), buffer_len(bout));
if (buffer_len(berr) > 0)
- atomicio(write, fileno(stderr), buffer_ptr(berr), buffer_len(berr));
+ atomicio(vwrite, fileno(stderr), buffer_ptr(berr), buffer_len(berr));
leave_raw_mode();
diff --git a/monitor_wrap.c b/monitor_wrap.c
index bd3a01a2..10a79c03 100644
--- a/monitor_wrap.c
+++ b/monitor_wrap.c
@@ -25,7 +25,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: monitor_wrap.c,v 1.26 2003/04/07 08:29:57 markus Exp $");
+RCSID("$OpenBSD: monitor_wrap.c,v 1.27 2003/06/28 16:23:06 deraadt Exp $");
#include <openssl/bn.h>
#include <openssl/dh.h>
@@ -72,9 +72,9 @@ mm_request_send(int socket, enum monitor_reqtype type, Buffer *m)
PUT_32BIT(buf, mlen + 1);
buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */
- if (atomicio(write, socket, buf, sizeof(buf)) != sizeof(buf))
+ if (atomicio(vwrite, socket, buf, sizeof(buf)) != sizeof(buf))
fatal("%s: write", __func__);
- if (atomicio(write, socket, buffer_ptr(m), mlen) != mlen)
+ if (atomicio(vwrite, socket, buffer_ptr(m), mlen) != mlen)
fatal("%s: write", __func__);
}
diff --git a/msg.c b/msg.c
index 5d266c20..6a806c3f 100644
--- a/msg.c
+++ b/msg.c
@@ -22,7 +22,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "includes.h"
-RCSID("$OpenBSD: msg.c,v 1.5 2002/12/19 00:07:02 djm Exp $");
+RCSID("$OpenBSD: msg.c,v 1.6 2003/06/28 16:23:06 deraadt Exp $");
#include "buffer.h"
#include "getput.h"
@@ -40,9 +40,9 @@ ssh_msg_send(int fd, u_char type, Buffer *m)
PUT_32BIT(buf, mlen + 1);
buf[4] = type; /* 1st byte of payload is mesg-type */
- if (atomicio(write, fd, buf, sizeof(buf)) != sizeof(buf))
+ if (atomicio(vwrite, fd, buf, sizeof(buf)) != sizeof(buf))
fatal("ssh_msg_send: write");
- if (atomicio(write, fd, buffer_ptr(m), mlen) != mlen)
+ if (atomicio(vwrite, fd, buffer_ptr(m), mlen) != mlen)
fatal("ssh_msg_send: write");
}
diff --git a/progressmeter.c b/progressmeter.c
index a3f14c92..6aa225ad 100644
--- a/progressmeter.c
+++ b/progressmeter.c
@@ -64,7 +64,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: progressmeter.c,v 1.7 2003/06/10 22:20:52 deraadt Exp $");
+RCSID("$OpenBSD: progressmeter.c,v 1.8 2003/06/28 16:23:06 deraadt Exp $");
#ifdef HAVE_LIBGEN_H
#include <libgen.h>
@@ -132,7 +132,7 @@ stop_progress_meter(void)
alarm(0);
draw_progress_meter();
if (foregroundproc() != 0)
- atomicio(write, fileno(stdout), "\n", 1);
+ atomicio(vwrite, fileno(stdout), "\n", 1);
}
static void
@@ -255,7 +255,7 @@ draw_progress_meter(void)
"%02d:%02d%s", i / 60, i % 60,
(cursize != totalbytes) ? " ETA" : " ");
}
- atomicio(write, fileno(stdout), buf, strlen(buf));
+ atomicio(vwrite, fileno(stdout), buf, strlen(buf));
}
static int
diff --git a/scp.c b/scp.c
index 1cd0c55a..81690609 100644
--- a/scp.c
+++ b/scp.c
@@ -71,7 +71,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: scp.c,v 1.106 2003/06/12 15:34:09 nino Exp $");
+RCSID("$OpenBSD: scp.c,v 1.107 2003/06/28 16:23:06 deraadt Exp $");
#include "xmalloc.h"
#include "atomicio.h"
@@ -549,7 +549,7 @@ syserr: run_err("%s: %s", name, strerror(errno));
(void) snprintf(buf, sizeof buf, "T%lu 0 %lu 0\n",
(u_long) stb.st_mtime,
(u_long) stb.st_atime);
- (void) atomicio(write, remout, buf, strlen(buf));
+ (void) atomicio(vwrite, remout, buf, strlen(buf));
if (response() < 0)
goto next;
}
@@ -560,7 +560,7 @@ syserr: run_err("%s: %s", name, strerror(errno));
if (verbose_mode) {
fprintf(stderr, "Sending file modes: %s", buf);
}
- (void) atomicio(write, remout, buf, strlen(buf));
+ (void) atomicio(vwrite, remout, buf, strlen(buf));
if (response() < 0)
goto next;
if ((bp = allocbuf(&buffer, fd, 2048)) == NULL) {
@@ -580,9 +580,9 @@ next: (void) close(fd);
haderr = result >= 0 ? EIO : errno;
}
if (haderr)
- (void) atomicio(write, remout, bp->buf, amt);
+ (void) atomicio(vwrite, remout, bp->buf, amt);
else {
- result = atomicio(write, remout, bp->buf, amt);
+ result = atomicio(vwrite, remout, bp->buf, amt);
if (result != amt)
haderr = result >= 0 ? EIO : errno;
statbytes += result;
@@ -596,7 +596,7 @@ next: (void) close(fd);
if (close(fd) < 0 && !haderr)
haderr = errno;
if (!haderr)
- (void) atomicio(write, remout, "", 1);
+ (void) atomicio(vwrite, remout, "", 1);
else
run_err("%s: %s", name, strerror(haderr));
(void) response();
@@ -623,7 +623,7 @@ rsource(char *name, struct stat *statp)
(void) snprintf(path, sizeof(path), "T%lu 0 %lu 0\n",
(u_long) statp->st_mtime,
(u_long) statp->st_atime);
- (void) atomicio(write, remout, path, strlen(path));
+ (void) atomicio(vwrite, remout, path, strlen(path));
if (response() < 0) {
closedir(dirp);
return;
@@ -633,7 +633,7 @@ rsource(char *name, struct stat *statp)
(u_int) (statp->st_mode & FILEMODEMASK), 0, last);
if (verbose_mode)
fprintf(stderr, "Entering directory: %s", path);
- (void) atomicio(write, remout, path, strlen(path));
+ (void) atomicio(vwrite, remout, path, strlen(path));
if (response() < 0) {
closedir(dirp);
return;
@@ -652,7 +652,7 @@ rsource(char *name, struct stat *statp)
source(1, vect);
}
(void) closedir(dirp);
- (void) atomicio(write, remout, "E\n", 2);
+ (void) atomicio(vwrite, remout, "E\n", 2);
(void) response();
}
@@ -742,7 +742,7 @@ sink(int argc, char **argv)
if (targetshouldbedirectory)
verifydir(targ);
- (void) atomicio(write, remout, "", 1);
+ (void) atomicio(vwrite, remout, "", 1);
if (stat(targ, &stb) == 0 && S_ISDIR(stb.st_mode))
targisdir = 1;
for (first = 1;; first = 0) {
@@ -760,7 +760,7 @@ sink(int argc, char **argv)
if (buf[0] == '\01' || buf[0] == '\02') {
if (iamremote == 0)
- (void) atomicio(write, STDERR_FILENO,
+ (void) atomicio(vwrite, STDERR_FILENO,
buf + 1, strlen(buf + 1));
if (buf[0] == '\02')
exit(1);
@@ -768,7 +768,7 @@ sink(int argc, char **argv)
continue;
}
if (buf[0] == 'E') {
- (void) atomicio(write, remout, "", 1);
+ (void) atomicio(vwrite, remout, "", 1);
return;
}
if (ch == '\n')
@@ -790,7 +790,7 @@ sink(int argc, char **argv)
atime.tv_usec = strtol(cp, &cp, 10);
if (!cp || *cp++ != '\0')
SCREWUP("atime.usec not delimited");
- (void) atomicio(write, remout, "", 1);
+ (void) atomicio(vwrite, remout, "", 1);
continue;
}
if (*cp != 'C' && *cp != 'D') {
@@ -875,7 +875,7 @@ sink(int argc, char **argv)
bad: run_err("%s: %s", np, strerror(errno));
continue;
}
- (void) atomicio(write, remout, "", 1);
+ (void) atomicio(vwrite, remout, "", 1);
if ((bp = allocbuf(&buffer, ofd, 4096)) == NULL) {
(void) close(ofd);
continue;
@@ -912,7 +912,7 @@ bad: run_err("%s: %s", np, strerror(errno));
if (count == bp->cnt) {
/* Keep reading so we stay sync'd up. */
if (wrerr == NO) {
- j = atomicio(write, ofd, bp->buf, count);
+ j = atomicio(vwrite, ofd, bp->buf, count);
if (j != count) {
wrerr = YES;
wrerrno = j >= 0 ? EIO : errno;
@@ -925,7 +925,7 @@ bad: run_err("%s: %s", np, strerror(errno));
if (showprogress)
stop_progress_meter();
if (count != 0 && wrerr == NO &&
- (j = atomicio(write, ofd, bp->buf, count)) != count) {
+ (j = atomicio(vwrite, ofd, bp->buf, count)) != count) {
wrerr = YES;
wrerrno = j >= 0 ? EIO : errno;
}
@@ -970,7 +970,7 @@ bad: run_err("%s: %s", np, strerror(errno));
run_err("%s: %s", np, strerror(wrerrno));
break;
case NO:
- (void) atomicio(write, remout, "", 1);
+ (void) atomicio(vwrite, remout, "", 1);
break;
case DISPLAYED:
break;
@@ -1005,7 +1005,7 @@ response(void)
} while (cp < &rbuf[sizeof(rbuf) - 1] && ch != '\n');
if (!iamremote)
- (void) atomicio(write, STDERR_FILENO, rbuf, cp - rbuf);
+ (void) atomicio(vwrite, STDERR_FILENO, rbuf, cp - rbuf);
++errs;
if (resp == 1)
return (-1);
diff --git a/sftp-client.c b/sftp-client.c
index a48d56e6..ffff0fe5 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -28,7 +28,7 @@
/* XXX: copy between two remote sites */
#include "includes.h"
-RCSID("$OpenBSD: sftp-client.c,v 1.43 2003/04/08 20:21:29 itojun Exp $");
+RCSID("$OpenBSD: sftp-client.c,v 1.44 2003/06/28 16:23:06 deraadt Exp $");
#include "openbsd-compat/sys-queue.h"
@@ -71,10 +71,10 @@ send_msg(int fd, Buffer *m)
/* Send length first */
PUT_32BIT(mlen, buffer_len(m));
- if (atomicio(write, fd, mlen, sizeof(mlen)) <= 0)
+ if (atomicio(vwrite, fd, mlen, sizeof(mlen)) <= 0)
fatal("Couldn't send packet: %s", strerror(errno));
- if (atomicio(write, fd, buffer_ptr(m), buffer_len(m)) <= 0)
+ if (atomicio(vwrite, fd, buffer_ptr(m), buffer_len(m)) <= 0)
fatal("Couldn't send packet: %s", strerror(errno));
buffer_clear(m);
@@ -875,7 +875,7 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
fatal("Received more data than asked for "
"%u > %u", len, req->len);
if ((lseek(local_fd, req->offset, SEEK_SET) == -1 ||
- atomicio(write, local_fd, data, len) != len) &&
+ atomicio(vwrite, local_fd, data, len) != len) &&
!write_error) {
write_errno = errno;
write_error = 1;
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index e2cd789b..358a1e35 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -7,7 +7,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-keyscan.c,v 1.43 2003/04/26 04:29:49 deraadt Exp $");
+RCSID("$OpenBSD: ssh-keyscan.c,v 1.44 2003/06/28 16:23:06 deraadt Exp $");
#include "openbsd-compat/sys-queue.h"
@@ -541,7 +541,7 @@ congreet(int s)
n = snprintf(buf, sizeof buf, "SSH-%d.%d-OpenSSH-keyscan\r\n",
c->c_keytype == KT_RSA1? PROTOCOL_MAJOR_1 : PROTOCOL_MAJOR_2,
c->c_keytype == KT_RSA1? PROTOCOL_MINOR_1 : PROTOCOL_MINOR_2);
- if (atomicio(write, s, buf, n) != n) {
+ if (atomicio(vwrite, s, buf, n) != n) {
error("write (%s): %s", c->c_name, strerror(errno));
confree(s);
return;
diff --git a/ssh.h b/ssh.h
index a2d47e1e..25a9213f 100644
--- a/ssh.h
+++ b/ssh.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh.h,v 1.71 2002/06/22 02:00:29 stevesk Exp $ */
+/* $OpenBSD: ssh.h,v 1.72 2003/06/28 16:23:06 deraadt Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -107,3 +107,4 @@
#define SSH_RSA_MINIMUM_MODULUS_SIZE 768
#endif /* SSH_H */
+
diff --git a/sshconnect.c b/sshconnect.c
index 82f5539c..364a6228 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -13,7 +13,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshconnect.c,v 1.145 2003/06/11 10:16:16 jakob Exp $");
+RCSID("$OpenBSD: sshconnect.c,v 1.146 2003/06/28 16:23:06 deraadt Exp $");
#include <openssl/bn.h>
@@ -523,7 +523,7 @@ ssh_exchange_identification(void)
compat20 ? PROTOCOL_MAJOR_2 : PROTOCOL_MAJOR_1,
compat20 ? PROTOCOL_MINOR_2 : minor1,
SSH_VERSION);
- if (atomicio(write, connection_out, buf, strlen(buf)) != strlen(buf))
+ if (atomicio(vwrite, connection_out, buf, strlen(buf)) != strlen(buf))
fatal("write: %.100s", strerror(errno));
client_version_string = xstrdup(buf);
chop(client_version_string);
diff --git a/sshd.c b/sshd.c
index b4cdc724..fafe0c66 100644
--- a/sshd.c
+++ b/sshd.c
@@ -42,7 +42,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshd.c,v 1.270 2003/06/28 07:48:10 djm Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.271 2003/06/28 16:23:06 deraadt Exp $");
#include <openssl/dh.h>
#include <openssl/bn.h>
@@ -369,7 +369,7 @@ sshd_exchange_identification(int sock_in, int sock_out)
if (client_version_string == NULL) {
/* Send our protocol version identification. */
- if (atomicio(write, sock_out, server_version_string,
+ if (atomicio(vwrite, sock_out, server_version_string,
strlen(server_version_string))
!= strlen(server_version_string)) {
logit("Could not write ident string to %s", get_remote_ipaddr());
@@ -408,7 +408,7 @@ sshd_exchange_identification(int sock_in, int sock_out)
if (sscanf(client_version_string, "SSH-%d.%d-%[^\n]\n",
&remote_major, &remote_minor, remote_version) != 3) {
s = "Protocol mismatch.\n";
- (void) atomicio(write, sock_out, s, strlen(s));
+ (void) atomicio(vwrite, sock_out, s, strlen(s));
close(sock_in);
close(sock_out);
logit("Bad protocol version identification '%.100s' from %s",
@@ -469,7 +469,7 @@ sshd_exchange_identification(int sock_in, int sock_out)
if (mismatch) {
s = "Protocol major versions differ.\n";
- (void) atomicio(write, sock_out, s, strlen(s));
+ (void) atomicio(vwrite, sock_out, s, strlen(s));
close(sock_in);
close(sock_out);
logit("Protocol major versions differ for %s: %.200s vs. %.200s",