]> andersk Git - openssh.git/commitdiff
- stevesk@cvs.openbsd.org 2001/12/19 17:16:13
authordjm <djm>
Fri, 21 Dec 2001 03:56:54 +0000 (03:56 +0000)
committerdjm <djm>
Fri, 21 Dec 2001 03:56:54 +0000 (03:56 +0000)
     [authfile.c bufaux.c bufaux.h buffer.c buffer.h packet.c packet.h ssh.c]
     change the buffer/packet interface to use void* vs. char*; ok markus@

ChangeLog
authfile.c
bufaux.c
bufaux.h
buffer.c
buffer.h
packet.c
packet.h
ssh.c

index 6342594c82a6099b96b5446af33904dd49c6d239..967323ddec2852e04d8dcce8dbcc412ae51f93a3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -44,6 +44,9 @@
      to the pipe on SIGCHLD wakes up select(). using pselect() is not
      portable and siglongjmp() ugly. W. R. Stevens suggests similar solution.
      initial idea by pmenage@ensim.com; ok deraadt@, djm@
+   - stevesk@cvs.openbsd.org 2001/12/19 17:16:13
+     [authfile.c bufaux.c bufaux.h buffer.c buffer.h packet.c packet.h ssh.c]
+     change the buffer/packet interface to use void* vs. char*; ok markus@
 
 20011219
  - (stevesk) OpenBSD CVS sync X11 localhost display
index abf2877f59f9184bd45eeb4a56a7fea937b61aab..3bfca4ac581061be82031630cddd2b1f9e181dfa 100644 (file)
@@ -36,7 +36,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: authfile.c,v 1.41 2001/12/19 07:18:56 deraadt Exp $");
+RCSID("$OpenBSD: authfile.c,v 1.42 2001/12/19 17:16:13 stevesk Exp $");
 
 #include <openssl/err.h>
 #include <openssl/evp.h>
@@ -128,7 +128,7 @@ key_save_private_rsa1(Key *key, const char *filename, const char *passphrase,
        buffer_put_cstring(&encrypted, comment);
 
        /* Allocate space for the private part of the key in the buffer. */
-       buffer_append_space(&encrypted, &cp, buffer_len(&buffer));
+       cp = buffer_append_space(&encrypted, buffer_len(&buffer));
 
        cipher_set_key_string(&ciphercontext, cipher, passphrase);
        cipher_encrypt(&ciphercontext, (u_char *) cp,
@@ -239,7 +239,7 @@ key_load_public_rsa1(int fd, const char *filename, char **commentp)
        lseek(fd, (off_t) 0, SEEK_SET);
 
        buffer_init(&buffer);
-       buffer_append_space(&buffer, &cp, len);
+       cp = buffer_append_space(&buffer, len);
 
        if (read(fd, cp, (size_t) len) != (size_t) len) {
                debug("Read from key file %.200s failed: %.100s", filename,
@@ -324,7 +324,7 @@ key_load_private_rsa1(int fd, const char *filename, const char *passphrase,
        lseek(fd, (off_t) 0, SEEK_SET);
 
        buffer_init(&buffer);
-       buffer_append_space(&buffer, &cp, len);
+       cp = buffer_append_space(&buffer, len);
 
        if (read(fd, cp, (size_t) len) != (size_t) len) {
                debug("Read from key file %.200s failed: %.100s", filename,
@@ -378,7 +378,7 @@ key_load_private_rsa1(int fd, const char *filename, const char *passphrase,
        }
        /* Initialize space for decrypted data. */
        buffer_init(&decrypted);
-       buffer_append_space(&decrypted, &cp, buffer_len(&buffer));
+       cp = buffer_append_space(&decrypted, buffer_len(&buffer));
 
        /* Rest of the buffer is encrypted.  Decrypt it using the passphrase. */
        cipher_set_key_string(&ciphercontext, cipher, passphrase);
index 5bc7186238713e5114f3a3448a9de16ce64c8e45..7fbd0d02ef72d4041f54b481bb12cf064b956105 100644 (file)
--- a/bufaux.c
+++ b/bufaux.c
@@ -37,7 +37,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: bufaux.c,v 1.19 2001/12/19 07:18:56 deraadt Exp $");
+RCSID("$OpenBSD: bufaux.c,v 1.20 2001/12/19 17:16:13 stevesk Exp $");
 
 #include <openssl/bn.h>
 #include "bufaux.h"
@@ -191,11 +191,11 @@ buffer_put_int64(Buffer *buffer, u_int64_t value)
  * will be stored there.  A null character will be automatically appended
  * to the returned string, and is not counted in length.
  */
-char *
+void *
 buffer_get_string(Buffer *buffer, u_int *length_ptr)
 {
        u_int len;
-       char *value;
+       u_char *value;
        /* Get the length. */
        len = buffer_get_int(buffer);
        if (len > 256 * 1024)
index d1af09881b1e95715833ccc0aea570cacadb3c29..521ddf135caadc5c724a587c11dc012f55e93a60 100644 (file)
--- a/bufaux.h
+++ b/bufaux.h
@@ -10,7 +10,7 @@
  * called by a name other than "ssh" or "Secure Shell".
  */
 
-/* RCSID("$OpenBSD: bufaux.h,v 1.13 2001/06/26 17:27:22 markus Exp $"); */
+/* RCSID("$OpenBSD: bufaux.h,v 1.14 2001/12/19 17:16:13 stevesk Exp $"); */
 
 #ifndef BUFAUX_H
 #define BUFAUX_H
@@ -36,7 +36,7 @@ int     buffer_get_char(Buffer *);
 
 void    buffer_put_char(Buffer *, int);
 
-char   *buffer_get_string(Buffer *, u_int *);
+void   *buffer_get_string(Buffer *, u_int *);
 
 void    buffer_put_string(Buffer *, const void *, u_int);
 void   buffer_put_cstring(Buffer *, const char *);
index 044caafb5d73b653d5d985b46afbf10d6d1e979e..a1152d1d6f56567f81fff3b34b95f9661714bc4b 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -12,7 +12,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: buffer.c,v 1.13 2001/04/12 19:15:24 markus Exp $");
+RCSID("$OpenBSD: buffer.c,v 1.14 2001/12/19 17:16:13 stevesk Exp $");
 
 #include "xmalloc.h"
 #include "buffer.h"
@@ -53,11 +53,11 @@ buffer_clear(Buffer *buffer)
 /* Appends data to the buffer, expanding it if necessary. */
 
 void
-buffer_append(Buffer *buffer, const char *data, u_int len)
+buffer_append(Buffer *buffer, const void *data, u_int len)
 {
-       char *cp;
-       buffer_append_space(buffer, &cp, len);
-       memcpy(cp, data, len);
+       void *p;
+       p = buffer_append_space(buffer, len);
+       memcpy(p, data, len);
 }
 
 /*
@@ -66,9 +66,11 @@ buffer_append(Buffer *buffer, const char *data, u_int len)
  * to the allocated region.
  */
 
-void
-buffer_append_space(Buffer *buffer, char **datap, u_int len)
+void *
+buffer_append_space(Buffer *buffer, u_int len)
 {
+       void *p;
+
        /* If the buffer is empty, start using it from the beginning. */
        if (buffer->offset == buffer->end) {
                buffer->offset = 0;
@@ -77,9 +79,9 @@ buffer_append_space(Buffer *buffer, char **datap, u_int len)
 restart:
        /* If there is enough space to store all data, store it now. */
        if (buffer->end + len < buffer->alloc) {
-               *datap = buffer->buf + buffer->end;
+               p = buffer->buf + buffer->end;
                buffer->end += len;
-               return;
+               return p;
        }
        /*
         * If the buffer is quite empty, but all data is at the end, move the
@@ -96,6 +98,7 @@ restart:
        buffer->alloc += len + 32768;
        buffer->buf = xrealloc(buffer->buf, buffer->alloc);
        goto restart;
+       /* NOTREACHED */
 }
 
 /* Returns the number of bytes of data in the buffer. */
@@ -109,7 +112,7 @@ buffer_len(Buffer *buffer)
 /* Gets data from the beginning of the buffer. */
 
 void
-buffer_get(Buffer *buffer, char *buf, u_int len)
+buffer_get(Buffer *buffer, void *buf, u_int len)
 {
        if (len > buffer->end - buffer->offset)
                fatal("buffer_get: trying to get more bytes %d than in buffer %d",
@@ -140,7 +143,7 @@ buffer_consume_end(Buffer *buffer, u_int bytes)
 
 /* Returns a pointer to the first used byte in the buffer. */
 
-char *
+void *
 buffer_ptr(Buffer *buffer)
 {
        return buffer->buf + buffer->offset;
index 845bfb69707c4445bbae5cd2e4fdb5846f7a217b..badd16f3bb8f10817e4755a3069b8cb2dc450c1e 100644 (file)
--- a/buffer.h
+++ b/buffer.h
  * called by a name other than "ssh" or "Secure Shell".
  */
 
-/* RCSID("$OpenBSD: buffer.h,v 1.9 2001/06/26 17:27:23 markus Exp $"); */
+/* RCSID("$OpenBSD: buffer.h,v 1.10 2001/12/19 17:16:13 stevesk Exp $"); */
 
 #ifndef BUFFER_H
 #define BUFFER_H
 
 typedef struct {
-       char    *buf;           /* Buffer for data. */
+       u_char  *buf;           /* Buffer for data. */
        u_int    alloc;         /* Number of bytes allocated for data. */
        u_int    offset;        /* Offset of first byte containing data. */
        u_int    end;           /* Offset of last byte containing data. */
@@ -28,12 +28,12 @@ void         buffer_clear(Buffer *);
 void    buffer_free(Buffer *);
 
 u_int   buffer_len(Buffer *);
-char   *buffer_ptr(Buffer *);
+void   *buffer_ptr(Buffer *);
 
-void    buffer_append(Buffer *, const char *, u_int);
-void    buffer_append_space(Buffer *, char **, u_int);
+void    buffer_append(Buffer *, const void *, u_int);
+void   *buffer_append_space(Buffer *, u_int);
 
-void    buffer_get(Buffer *, char *, u_int);
+void    buffer_get(Buffer *, void *, u_int);
 
 void    buffer_consume(Buffer *, u_int);
 void    buffer_consume_end(Buffer *, u_int);
index 9aeda39365d7b4a8e4343e8619cfb5c260bd6f51..4b3eafc880b7b76b55a406ab886d8d5c673ed7dc 100644 (file)
--- a/packet.c
+++ b/packet.c
@@ -37,7 +37,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: packet.c,v 1.75 2001/12/19 07:18:56 deraadt Exp $");
+RCSID("$OpenBSD: packet.c,v 1.76 2001/12/19 17:16:13 stevesk Exp $");
 
 #include "xmalloc.h"
 #include "buffer.h"
@@ -329,7 +329,7 @@ packet_put_int(u_int value)
        buffer_put_int(&outgoing_packet, value);
 }
 void
-packet_put_string(const char *buf, u_int len)
+packet_put_string(const void *buf, u_int len)
 {
        buffer_put_string(&outgoing_packet, buf, len);
 }
@@ -339,7 +339,7 @@ packet_put_cstring(const char *str)
        buffer_put_cstring(&outgoing_packet, str);
 }
 void
-packet_put_raw(const char *buf, u_int len)
+packet_put_raw(const void *buf, u_int len)
 {
        buffer_append(&outgoing_packet, buf, len);
 }
@@ -412,7 +412,7 @@ packet_send1(void)
        /* Append to output. */
        PUT_32BIT(buf, len);
        buffer_append(&output, buf, 4);
-       buffer_append_space(&output, &cp, buffer_len(&outgoing_packet));
+       cp = buffer_append_space(&output, buffer_len(&outgoing_packet));
        cipher_encrypt(&send_context, cp, buffer_ptr(&outgoing_packet),
            buffer_len(&outgoing_packet));
 
@@ -546,7 +546,7 @@ packet_send2(void)
                padlen += pad;
                extra_pad = 0;
        }
-       buffer_append_space(&outgoing_packet, &cp, padlen);
+       cp = buffer_append_space(&outgoing_packet, padlen);
        if (enc && enc->cipher->number != SSH_CIPHER_NONE) {
                /* random padding */
                for (i = 0; i < padlen; i++) {
@@ -574,7 +574,7 @@ packet_send2(void)
                DBG(debug("done calc MAC out #%d", seqnr));
        }
        /* encrypt packet and append to output buffer. */
-       buffer_append_space(&output, &cp, buffer_len(&outgoing_packet));
+       cp = buffer_append_space(&output, buffer_len(&outgoing_packet));
        cipher_encrypt(&send_context, cp, buffer_ptr(&outgoing_packet),
            buffer_len(&outgoing_packet));
        /* append unencrypted MAC */
@@ -734,7 +734,7 @@ packet_read_poll1(int *payload_len_ptr)
 
        /* Decrypt data to incoming_packet. */
        buffer_clear(&incoming_packet);
-       buffer_append_space(&incoming_packet, &cp, padded_len);
+       cp = buffer_append_space(&incoming_packet, padded_len);
        cipher_decrypt(&receive_context, cp, buffer_ptr(&input), padded_len);
 
        buffer_consume(&input, padded_len);
@@ -803,7 +803,7 @@ packet_read_poll2(int *payload_len_ptr)
                if (buffer_len(&input) < block_size)
                        return SSH_MSG_NONE;
                buffer_clear(&incoming_packet);
-               buffer_append_space(&incoming_packet, &cp, block_size);
+               cp = buffer_append_space(&incoming_packet, block_size);
                cipher_decrypt(&receive_context, cp, buffer_ptr(&input),
                    block_size);
                ucp = (u_char *) buffer_ptr(&incoming_packet);
@@ -832,7 +832,7 @@ packet_read_poll2(int *payload_len_ptr)
        fprintf(stderr, "read_poll enc/full: ");
        buffer_dump(&input);
 #endif
-       buffer_append_space(&incoming_packet, &cp, need);
+       cp = buffer_append_space(&incoming_packet, need);
        cipher_decrypt(&receive_context, cp, buffer_ptr(&input), need);
        buffer_consume(&input, need);
        /*
@@ -852,7 +852,8 @@ packet_read_poll2(int *payload_len_ptr)
                log("incoming seqnr wraps around");
 
        /* get padlen */
-       cp = buffer_ptr(&incoming_packet) + 4;
+       cp = buffer_ptr(&incoming_packet);
+       cp += 4;
        padlen = (u_char) *cp;
        DBG(debug("input: padlen %d", padlen));
        if (padlen < 4)
@@ -996,7 +997,7 @@ packet_get_bignum2(BIGNUM * value, int *length_ptr)
        *length_ptr = buffer_get_bignum2(&incoming_packet, value);
 }
 
-char *
+void *
 packet_get_raw(int *length_ptr)
 {
        int bytes = buffer_len(&incoming_packet);
@@ -1018,7 +1019,7 @@ packet_remaining(void)
  * integer into which the length of the string is stored.
  */
 
-char *
+void *
 packet_get_string(u_int *length_ptr)
 {
        return buffer_get_string(&incoming_packet, length_ptr);
index d5473001c5041ec78a0312c6779fb1af0b0a085d..d281042f1c784fa47fe0c81a2be294943e8eb2a7 100644 (file)
--- a/packet.h
+++ b/packet.h
@@ -11,7 +11,7 @@
  * called by a name other than "ssh" or "Secure Shell".
  */
 
-/* RCSID("$OpenBSD: packet.h,v 1.26 2001/11/07 16:03:17 markus Exp $"); */
+/* RCSID("$OpenBSD: packet.h,v 1.27 2001/12/19 17:16:13 stevesk Exp $"); */
 
 #ifndef PACKET_H
 #define PACKET_H
@@ -35,9 +35,9 @@ void     packet_put_char(int ch);
 void     packet_put_int(u_int value);
 void     packet_put_bignum(BIGNUM * value);
 void     packet_put_bignum2(BIGNUM * value);
-void     packet_put_string(const char *buf, u_int len);
+void     packet_put_string(const void *buf, u_int len);
 void     packet_put_cstring(const char *str);
-void     packet_put_raw(const char *buf, u_int len);
+void     packet_put_raw(const void *buf, u_int len);
 void     packet_send(void);
 
 int      packet_read(int *payload_len_ptr);
@@ -49,8 +49,8 @@ u_int  packet_get_char(void);
 u_int   packet_get_int(void);
 void     packet_get_bignum(BIGNUM * value, int *length_ptr);
 void     packet_get_bignum2(BIGNUM * value, int *length_ptr);
-char   *packet_get_raw(int *length_ptr);
-char    *packet_get_string(u_int *length_ptr);
+void   *packet_get_raw(int *length_ptr);
+void   *packet_get_string(u_int *length_ptr);
 void     packet_disconnect(const char *fmt,...) __attribute__((format(printf, 1, 2)));
 void     packet_send_debug(const char *fmt,...) __attribute__((format(printf, 1, 2)));
 
diff --git a/ssh.c b/ssh.c
index aa557eb0347aaff021f24edd83d787a15c2082af..9ec63ab9a40767d5ea0e335274e34146195b3270 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -39,7 +39,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: ssh.c,v 1.151 2001/12/19 07:18:56 deraadt Exp $");
+RCSID("$OpenBSD: ssh.c,v 1.152 2001/12/19 17:16:13 stevesk Exp $");
 
 #include <openssl/evp.h>
 #include <openssl/err.h>
@@ -997,7 +997,7 @@ ssh_session(void)
                int len = buffer_len(&command);
                if (len > 900)
                        len = 900;
-               debug("Sending command: %.*s", len, buffer_ptr(&command));
+               debug("Sending command: %.*s", len, (u_char *)buffer_ptr(&command));
                packet_start(SSH_CMSG_EXEC_CMD);
                packet_put_string(buffer_ptr(&command), buffer_len(&command));
                packet_send();
@@ -1026,7 +1026,7 @@ client_subsystem_reply(int type, int plen, void *ctxt)
        packet_done();
        if (type == SSH2_MSG_CHANNEL_FAILURE)
                fatal("Request for subsystem '%.*s' failed on channel %d",
-                   len, buffer_ptr(&command), id);
+                   len, (u_char *)buffer_ptr(&command), id);
 }
 
 /* request pty/x11/agent/tcpfwd/shell for channel */
@@ -1085,14 +1085,14 @@ ssh_session2_setup(int id, void *arg)
                if (len > 900)
                        len = 900;
                if (subsystem_flag) {
-                       debug("Sending subsystem: %.*s", len, buffer_ptr(&command));
+                       debug("Sending subsystem: %.*s", len, (u_char *)buffer_ptr(&command));
                        channel_request_start(id, "subsystem", /*want reply*/ 1);
                        /* register callback for reply */
                        /* XXX we asume that client_loop has already been called */
                        dispatch_set(SSH2_MSG_CHANNEL_FAILURE, &client_subsystem_reply);
                        dispatch_set(SSH2_MSG_CHANNEL_SUCCESS, &client_subsystem_reply);
                } else {
-                       debug("Sending command: %.*s", len, buffer_ptr(&command));
+                       debug("Sending command: %.*s", len, (u_char *)buffer_ptr(&command));
                        channel_request_start(id, "exec", 0);
                }
                packet_put_string(buffer_ptr(&command), buffer_len(&command));
This page took 0.077228 seconds and 5 git commands to generate.