]> andersk Git - openssh.git/commitdiff
- deraadt@cvs.openbsd.org 2003/06/28 16:23:06
authordtucker <dtucker>
Thu, 3 Jul 2003 03:46:56 +0000 (03:46 +0000)
committerdtucker <dtucker>
Thu, 3 Jul 2003 03:46:56 +0000 (03:46 +0000)
     [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

14 files changed:
ChangeLog
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

index 1b21876e44b95a6ff7f7a79eff8a0db976cccb1a..a4e27dcfc4e030f3f844af2f9ce9403d6f59bcb3 100644 (file)
--- 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 
index 47161eb3a1e3175ebbbd056e7ad9f5f96ba0dd4c..dfc1553c5c00c22c5c349e12dd8e189b0ff3a1f2 100644 (file)
@@ -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;
index e569d38c603f1bda7e55c335c3196eb51e9c115b..5c0f392effc4c974d76492a82be6e16023800556 100644 (file)
@@ -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
index 368544b17b65a02f04a88735f716febadbfae332..c78db6d9444397ca50b2002ac56990efa1413c4f 100644 (file)
--- 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;
index 1c1acf4812327ed59a753fb6ac12480e98136c24..d8def78bda79fbf91e8011a9df1d8a3f866a4b4b 100644 (file)
@@ -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();
 
index bd3a01a2bab4a0bb2f219207d6cca19ca12c4e02..10a79c0356baf1abdaaa0f08573e50b39e5ca0be 100644 (file)
@@ -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 5d266c207e57f5970e5f40d8f3135c3d2b50fbda..6a806c3f5a1fec68d9a8a25bec8fe00b4cd2cf92 100644 (file)
--- 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");
 }
 
index a3f14c929408432db5ac3ae84cc4c1511137bbbc..6aa225adf021c1a4205420a7201f41794d894bd7 100644 (file)
@@ -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 1cd0c55a46607411ee76ee4953d9889c627dfa04..81690609dd2fd92e660ba0efe91dfaf55832532c 100644 (file)
--- 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);
index a48d56e697ea7cba7c10fe393c112b0dafd824da..ffff0fe5affabf63a2762aac0c5bb2e419ce5080 100644 (file)
@@ -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;
index e2cd789b5e485d758a33afd15ce17bc035db51aa..358a1e3539c4def5f4dade1fffa0a599018dad09 100644 (file)
@@ -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 a2d47e1ef98a3eb42cb5bca7d461c5248d0f4527..25a9213f31573c42d02eef78835673ad1781a884 100644 (file)
--- 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>
 #define SSH_RSA_MINIMUM_MODULUS_SIZE   768
 
 #endif                         /* SSH_H */
+
index 82f5539c1f73b9caf64201cbc8ee37bf0ab8b1fe..364a62281df6637fd6f70fc2215bcf42ee9b7963 100644 (file)
@@ -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 b4cdc724a6822f9878cb990ee70a801d108073e0..fafe0c66d809f5d2f0cf511e90871bd9580f64d1 100644 (file)
--- 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",
This page took 0.086982 seconds and 5 git commands to generate.