diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2006-03-30 09:58:17 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2006-03-30 09:58:17 +0000 |
commit | 7eb9710e84a54498a77871f47feb8df3e857c43c (patch) | |
tree | 7fdb983bc5d18e1924e9c84823fb5d2d57a0a008 | |
parent | ede133f9b618e890fb221bced62edde9a7dab4cb (diff) |
replace {GET,PUT}_XXBIT macros with functionally similar functions,
silencing a heap of lint warnings. also allows them to use
__bounded__ checking which can't be applied to macros; requested
by and feedback from deraadt@
-rw-r--r-- | usr.bin/ssh/OVERVIEW | 2 | ||||
-rw-r--r-- | usr.bin/ssh/authfd.c | 8 | ||||
-rw-r--r-- | usr.bin/ssh/bufaux.c | 20 | ||||
-rw-r--r-- | usr.bin/ssh/deattack.c | 6 | ||||
-rw-r--r-- | usr.bin/ssh/getput.h | 58 | ||||
-rw-r--r-- | usr.bin/ssh/gss-serv.c | 8 | ||||
-rw-r--r-- | usr.bin/ssh/mac.c | 6 | ||||
-rw-r--r-- | usr.bin/ssh/misc.c | 93 | ||||
-rw-r--r-- | usr.bin/ssh/misc.h | 24 | ||||
-rw-r--r-- | usr.bin/ssh/monitor_wrap.c | 8 | ||||
-rw-r--r-- | usr.bin/ssh/msg.c | 8 | ||||
-rw-r--r-- | usr.bin/ssh/packet.c | 15 | ||||
-rw-r--r-- | usr.bin/ssh/sftp-client.c | 6 | ||||
-rw-r--r-- | usr.bin/ssh/sftp-server.c | 9 | ||||
-rw-r--r-- | usr.bin/ssh/ssh-agent.c | 5 |
15 files changed, 158 insertions, 118 deletions
diff --git a/usr.bin/ssh/OVERVIEW b/usr.bin/ssh/OVERVIEW index d1a768c109f..966310acb3a 100644 --- a/usr.bin/ssh/OVERVIEW +++ b/usr.bin/ssh/OVERVIEW @@ -162,8 +162,6 @@ these programs. - There are several other files in the distribution that contain various auxiliary routines: ssh.h the main header file for ssh (various definitions) - getput.h byte-order independent storage of integers includes.h includes most system headers. Lots of #ifdefs. - tildexpand.c expand tilde in file names uidswap.c uid-swapping xmalloc.c "safe" malloc routines diff --git a/usr.bin/ssh/authfd.c b/usr.bin/ssh/authfd.c index 2654892d030..0fa69bd2a8e 100644 --- a/usr.bin/ssh/authfd.c +++ b/usr.bin/ssh/authfd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: authfd.c,v 1.73 2006/03/25 18:29:35 deraadt Exp $ */ +/* $OpenBSD: authfd.c,v 1.74 2006/03/30 09:58:15 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -47,7 +47,6 @@ #include "buffer.h" #include "bufaux.h" #include "xmalloc.h" -#include "getput.h" #include "key.h" #include "authfd.h" #include "cipher.h" @@ -55,6 +54,7 @@ #include "compat.h" #include "log.h" #include "atomicio.h" +#include "misc.h" static int agent_present = 0; @@ -122,7 +122,7 @@ ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply /* Get the length of the message, and format it in the buffer. */ len = buffer_len(request); - PUT_32BIT(buf, len); + put_u32(buf, len); /* Send the length and then the packet to the agent. */ if (atomicio(vwrite, auth->fd, buf, 4) != 4 || @@ -141,7 +141,7 @@ ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply } /* Extract the length, and check it for sanity. */ - len = GET_32BIT(buf); + len = get_u32(buf); if (len > 256 * 1024) fatal("Authentication response too long: %u", len); diff --git a/usr.bin/ssh/bufaux.c b/usr.bin/ssh/bufaux.c index 21a2badf13c..4f9a89881d9 100644 --- a/usr.bin/ssh/bufaux.c +++ b/usr.bin/ssh/bufaux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bufaux.c,v 1.40 2006/03/25 18:56:54 deraadt Exp $ */ +/* $OpenBSD: bufaux.c,v 1.41 2006/03/30 09:58:15 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -42,8 +42,8 @@ #include <openssl/bn.h> #include "bufaux.h" #include "xmalloc.h" -#include "getput.h" #include "log.h" +#include "misc.h" /* * Stores an BIGNUM in the buffer with a 2-byte msb first bit count, followed @@ -68,7 +68,7 @@ buffer_put_bignum_ret(Buffer *buffer, const BIGNUM *value) } /* Store the number of bits in the buffer in two bytes, msb first. */ - PUT_16BIT(msg, bits); + put_u16(msg, bits); buffer_append(buffer, msg, 2); /* Store the binary data. */ buffer_append(buffer, buf, oi); @@ -100,7 +100,7 @@ buffer_get_bignum_ret(Buffer *buffer, BIGNUM *value) error("buffer_get_bignum_ret: invalid length"); return (-1); } - bits = GET_16BIT(buf); + bits = get_u16(buf); /* Compute the number of binary bytes that follow. */ bytes = (bits + 7) / 8; if (bytes > 8 * 1024) { @@ -219,7 +219,7 @@ buffer_get_short_ret(u_short *ret, Buffer *buffer) if (buffer_get_ret(buffer, (char *) buf, 2) == -1) return (-1); - *ret = GET_16BIT(buf); + *ret = get_u16(buf); return (0); } @@ -241,7 +241,7 @@ buffer_get_int_ret(u_int *ret, Buffer *buffer) if (buffer_get_ret(buffer, (char *) buf, 4) == -1) return (-1); - *ret = GET_32BIT(buf); + *ret = get_u32(buf); return (0); } @@ -263,7 +263,7 @@ buffer_get_int64_ret(u_int64_t *ret, Buffer *buffer) if (buffer_get_ret(buffer, (char *) buf, 8) == -1) return (-1); - *ret = GET_64BIT(buf); + *ret = get_u64(buf); return (0); } @@ -286,7 +286,7 @@ buffer_put_short(Buffer *buffer, u_short value) { char buf[2]; - PUT_16BIT(buf, value); + put_u16(buf, value); buffer_append(buffer, buf, 2); } @@ -295,7 +295,7 @@ buffer_put_int(Buffer *buffer, u_int value) { char buf[4]; - PUT_32BIT(buf, value); + put_u32(buf, value); buffer_append(buffer, buf, 4); } @@ -304,7 +304,7 @@ buffer_put_int64(Buffer *buffer, u_int64_t value) { char buf[8]; - PUT_64BIT(buf, value); + put_u64(buf, value); buffer_append(buffer, buf, 8); } diff --git a/usr.bin/ssh/deattack.c b/usr.bin/ssh/deattack.c index 2adf185e8de..fa397e6e8cb 100644 --- a/usr.bin/ssh/deattack.c +++ b/usr.bin/ssh/deattack.c @@ -1,4 +1,4 @@ -/* $OpenBSD: deattack.c,v 1.26 2006/03/25 13:17:01 djm Exp $ */ +/* $OpenBSD: deattack.c,v 1.27 2006/03/30 09:58:15 djm Exp $ */ /* * Cryptographic attack detector for ssh - source code * @@ -23,8 +23,8 @@ #include "deattack.h" #include "log.h" #include "crc32.h" -#include "getput.h" #include "xmalloc.h" +#include "misc.h" /* SSH Constants */ #define SSH_MAXBLOCKS (32 * 1024) @@ -42,7 +42,7 @@ /* Hash function (Input keys are cipher results) */ -#define HASH(x) GET_32BIT(x) +#define HASH(x) get_u32(x) #define CMP(a, b) (memcmp(a, b, SSH_BLOCKSIZE)) diff --git a/usr.bin/ssh/getput.h b/usr.bin/ssh/getput.h deleted file mode 100644 index e37c3b6aa0a..00000000000 --- a/usr.bin/ssh/getput.h +++ /dev/null @@ -1,58 +0,0 @@ -/* $OpenBSD: getput.h,v 1.9 2006/03/25 22:22:43 djm Exp $ */ - -/* - * Author: Tatu Ylonen <ylo@cs.hut.fi> - * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland - * All rights reserved - * Macros for storing and retrieving data in msb first and lsb first order. - * - * As far as I am concerned, the code I have written for this software - * can be used freely for any purpose. Any derived versions of this - * software must be clearly marked as such, and if the derived work is - * incompatible with the protocol description in the RFC file, it must be - * called by a name other than "ssh" or "Secure Shell". - */ - -#ifndef GETPUT_H -#define GETPUT_H - -/*------------ macros for storing/extracting msb first words -------------*/ - -#define GET_64BIT(cp) (((u_int64_t)(u_char)(cp)[0] << 56) | \ - ((u_int64_t)(u_char)(cp)[1] << 48) | \ - ((u_int64_t)(u_char)(cp)[2] << 40) | \ - ((u_int64_t)(u_char)(cp)[3] << 32) | \ - ((u_int64_t)(u_char)(cp)[4] << 24) | \ - ((u_int64_t)(u_char)(cp)[5] << 16) | \ - ((u_int64_t)(u_char)(cp)[6] << 8) | \ - ((u_int64_t)(u_char)(cp)[7])) - -#define GET_32BIT(cp) (((u_long)(u_char)(cp)[0] << 24) | \ - ((u_long)(u_char)(cp)[1] << 16) | \ - ((u_long)(u_char)(cp)[2] << 8) | \ - ((u_long)(u_char)(cp)[3])) - -#define GET_16BIT(cp) (((u_long)(u_char)(cp)[0] << 8) | \ - ((u_long)(u_char)(cp)[1])) - -#define PUT_64BIT(cp, value) do { \ - (cp)[0] = (value) >> 56; \ - (cp)[1] = (value) >> 48; \ - (cp)[2] = (value) >> 40; \ - (cp)[3] = (value) >> 32; \ - (cp)[4] = (value) >> 24; \ - (cp)[5] = (value) >> 16; \ - (cp)[6] = (value) >> 8; \ - (cp)[7] = (value); } while (0) - -#define PUT_32BIT(cp, value) do { \ - (cp)[0] = (value) >> 24; \ - (cp)[1] = (value) >> 16; \ - (cp)[2] = (value) >> 8; \ - (cp)[3] = (value); } while (0) - -#define PUT_16BIT(cp, value) do { \ - (cp)[0] = (value) >> 8; \ - (cp)[1] = (value); } while (0) - -#endif /* GETPUT_H */ diff --git a/usr.bin/ssh/gss-serv.c b/usr.bin/ssh/gss-serv.c index 53ec634e866..5e43ffe5897 100644 --- a/usr.bin/ssh/gss-serv.c +++ b/usr.bin/ssh/gss-serv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gss-serv.c,v 1.16 2006/03/25 22:22:43 djm Exp $ */ +/* $OpenBSD: gss-serv.c,v 1.17 2006/03/30 09:58:15 djm Exp $ */ /* * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. @@ -35,7 +35,7 @@ #include "session.h" #include "servconf.h" #include "xmalloc.h" -#include "getput.h" +#include "misc.h" #include "ssh-gss.h" @@ -153,7 +153,7 @@ ssh_gssapi_parse_ename(Gssctxt *ctx, gss_buffer_t ename, gss_buffer_t name) * second without. */ - oidl = GET_16BIT(tok+2); /* length including next two bytes */ + oidl = get_u16(tok+2); /* length including next two bytes */ oidl = oidl-2; /* turn it into the _real_ length of the variable OID */ /* @@ -170,7 +170,7 @@ ssh_gssapi_parse_ename(Gssctxt *ctx, gss_buffer_t ename, gss_buffer_t name) if (ename->length < offset+4) return GSS_S_FAILURE; - name->length = GET_32BIT(tok+offset); + name->length = get_u32(tok+offset); offset += 4; if (ename->length < offset+name->length) diff --git a/usr.bin/ssh/mac.c b/usr.bin/ssh/mac.c index c155dbd3f8d..02bcc31edb0 100644 --- a/usr.bin/ssh/mac.c +++ b/usr.bin/ssh/mac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mac.c,v 1.9 2006/03/25 13:17:02 djm Exp $ */ +/* $OpenBSD: mac.c,v 1.10 2006/03/30 09:58:15 djm Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -28,11 +28,11 @@ #include <openssl/hmac.h> #include "xmalloc.h" -#include "getput.h" #include "log.h" #include "cipher.h" #include "kex.h" #include "mac.h" +#include "misc.h" struct { char *name; @@ -83,7 +83,7 @@ mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen) if (mac->mac_len > sizeof(m)) fatal("mac_compute: mac too long"); HMAC_Init(&c, mac->key, mac->key_len, mac->md); - PUT_32BIT(b, seqno); + put_u32(b, seqno); HMAC_Update(&c, b, sizeof(b)); HMAC_Update(&c, data, datalen); HMAC_Final(&c, m, NULL); diff --git a/usr.bin/ssh/misc.c b/usr.bin/ssh/misc.c index 4c89653924e..1cf35f2ca9b 100644 --- a/usr.bin/ssh/misc.c +++ b/usr.bin/ssh/misc.c @@ -1,7 +1,7 @@ -/* $OpenBSD: misc.c,v 1.51 2006/03/25 13:17:02 djm Exp $ */ +/* $OpenBSD: misc.c,v 1.52 2006/03/30 09:58:15 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. - * Copyright (c) 2005 Damien Miller. All rights reserved. + * Copyright (c) 2005,2006 Damien Miller. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -676,17 +676,100 @@ sanitise_stdfd(void) } char * -tohex(const u_char *d, u_int l) +tohex(const void *vp, size_t l) { + const u_char *p = (const u_char *)vp; char b[3], *r; - u_int i, hl; + size_t i, hl; + + if (l > 65536) + return xstrdup("tohex: length > 65536"); hl = l * 2 + 1; r = xcalloc(1, hl); for (i = 0; i < l; i++) { - snprintf(b, sizeof(b), "%02x", d[i]); + snprintf(b, sizeof(b), "%02x", p[i]); strlcat(r, b, hl); } return (r); } +u_int64_t +get_u64(const void *vp) +{ + const u_char *p = (const u_char *)vp; + u_int64_t v; + + v = (u_int64_t)p[0] << 56; + v |= (u_int64_t)p[1] << 48; + v |= (u_int64_t)p[2] << 40; + v |= (u_int64_t)p[3] << 32; + v |= (u_int64_t)p[4] << 24; + v |= (u_int64_t)p[5] << 16; + v |= (u_int64_t)p[6] << 8; + v |= (u_int64_t)p[7]; + + return (v); +} + +u_int32_t +get_u32(const void *vp) +{ + const u_char *p = (const u_char *)vp; + u_int32_t v; + + v = (u_int32_t)p[0] << 24; + v |= (u_int32_t)p[1] << 16; + v |= (u_int32_t)p[2] << 8; + v |= (u_int32_t)p[3]; + + return (v); +} + +u_int16_t +get_u16(const void *vp) +{ + const u_char *p = (const u_char *)vp; + u_int16_t v; + + v = (u_int16_t)p[0] << 8; + v |= (u_int16_t)p[1]; + + return (v); +} + +void +put_u64(void *vp, u_int64_t v) +{ + u_char *p = (u_char *)vp; + + p[0] = (u_char)(v >> 56) & 0xff; + p[1] = (u_char)(v >> 48) & 0xff; + p[2] = (u_char)(v >> 40) & 0xff; + p[3] = (u_char)(v >> 32) & 0xff; + p[4] = (u_char)(v >> 24) & 0xff; + p[5] = (u_char)(v >> 16) & 0xff; + p[6] = (u_char)(v >> 8) & 0xff; + p[7] = (u_char)v & 0xff; +} + +void +put_u32(void *vp, u_int32_t v) +{ + u_char *p = (u_char *)vp; + + p[0] = (u_char)(v >> 24) & 0xff; + p[1] = (u_char)(v >> 16) & 0xff; + p[2] = (u_char)(v >> 8) & 0xff; + p[3] = (u_char)v & 0xff; +} + + +void +put_u16(void *vp, u_int16_t v) +{ + u_char *p = (u_char *)vp; + + p[0] = (u_char)(v >> 8) & 0xff; + p[1] = (u_char)v & 0xff; +} diff --git a/usr.bin/ssh/misc.h b/usr.bin/ssh/misc.h index f20cb60bc61..bbd66ef106b 100644 --- a/usr.bin/ssh/misc.h +++ b/usr.bin/ssh/misc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.h,v 1.30 2006/03/25 22:22:43 djm Exp $ */ +/* $OpenBSD: misc.h,v 1.31 2006/03/30 09:58:15 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> @@ -12,6 +12,9 @@ * called by a name other than "ssh" or "Secure Shell". */ +#ifndef _MISC_H +#define _MISC_H + /* misc.c */ char *chop(char *); @@ -27,7 +30,7 @@ char *colon(char *); long convtime(const char *); char *tilde_expand_filename(const char *, uid_t); char *percent_expand(const char *, ...) __attribute__((__sentinel__)); -char *tohex(const u_char *, u_int); +char *tohex(const void *, size_t); void sanitise_stdfd(void); struct passwd *pwcopy(struct passwd *); @@ -67,3 +70,20 @@ int tun_open(int, int); #define SSH_TUNID_ANY 0x7fffffff #define SSH_TUNID_ERR (SSH_TUNID_ANY - 1) #define SSH_TUNID_MAX (SSH_TUNID_ANY - 2) + +/* Functions to extract or store big-endian words of various sizes */ +u_int64_t get_u64(const void *) + __attribute__((__bounded__( __minbytes__, 1, 8))); +u_int32_t get_u32(const void *) + __attribute__((__bounded__( __minbytes__, 1, 4))); +u_int16_t get_u16(const void *) + __attribute__((__bounded__( __minbytes__, 1, 2))); +void put_u64(void *, u_int64_t) + __attribute__((__bounded__( __minbytes__, 1, 8))); +void put_u32(void *, u_int32_t) + __attribute__((__bounded__( __minbytes__, 1, 4))); +void put_u16(void *, u_int16_t) + __attribute__((__bounded__( __minbytes__, 1, 2))); + +#endif /* _MISC_H */ + diff --git a/usr.bin/ssh/monitor_wrap.c b/usr.bin/ssh/monitor_wrap.c index 6d7ff6d0219..f95cd8c605d 100644 --- a/usr.bin/ssh/monitor_wrap.c +++ b/usr.bin/ssh/monitor_wrap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor_wrap.c,v 1.44 2006/03/25 13:17:02 djm Exp $ */ +/* $OpenBSD: monitor_wrap.c,v 1.45 2006/03/30 09:58:15 djm Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * Copyright 2002 Markus Friedl <markus@openbsd.org> @@ -46,7 +46,7 @@ #include "xmalloc.h" #include "atomicio.h" #include "monitor_fdpass.h" -#include "getput.h" +#include "misc.h" #include "auth.h" #include "channels.h" @@ -83,7 +83,7 @@ mm_request_send(int sock, enum monitor_reqtype type, Buffer *m) debug3("%s entering: type %d", __func__, type); - PUT_32BIT(buf, mlen + 1); + put_u32(buf, mlen + 1); buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */ if (atomicio(vwrite, sock, buf, sizeof(buf)) != sizeof(buf)) fatal("%s: write: %s", __func__, strerror(errno)); @@ -104,7 +104,7 @@ mm_request_receive(int sock, Buffer *m) cleanup_exit(255); fatal("%s: read: %s", __func__, strerror(errno)); } - msg_len = GET_32BIT(buf); + msg_len = get_u32(buf); if (msg_len > 256 * 1024) fatal("%s: read: bad msg_len %d", __func__, msg_len); buffer_clear(m); diff --git a/usr.bin/ssh/msg.c b/usr.bin/ssh/msg.c index 2c0a6726946..fb08df54872 100644 --- a/usr.bin/ssh/msg.c +++ b/usr.bin/ssh/msg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msg.c,v 1.10 2006/03/25 13:17:02 djm Exp $ */ +/* $OpenBSD: msg.c,v 1.11 2006/03/30 09:58:15 djm Exp $ */ /* * Copyright (c) 2002 Markus Friedl. All rights reserved. * @@ -25,10 +25,10 @@ #include "includes.h" #include "buffer.h" -#include "getput.h" #include "log.h" #include "atomicio.h" #include "msg.h" +#include "misc.h" int ssh_msg_send(int fd, u_char type, Buffer *m) @@ -38,7 +38,7 @@ ssh_msg_send(int fd, u_char type, Buffer *m) debug3("ssh_msg_send: type %u", (unsigned int)type & 0xff); - PUT_32BIT(buf, mlen + 1); + put_u32(buf, mlen + 1); buf[4] = type; /* 1st byte of payload is mesg-type */ if (atomicio(vwrite, fd, buf, sizeof(buf)) != sizeof(buf)) { error("ssh_msg_send: write"); @@ -64,7 +64,7 @@ ssh_msg_recv(int fd, Buffer *m) error("ssh_msg_recv: read: header"); return (-1); } - msg_len = GET_32BIT(buf); + msg_len = get_u32(buf); if (msg_len > 256 * 1024) { error("ssh_msg_recv: read: bad msg_len %u", msg_len); return (-1); diff --git a/usr.bin/ssh/packet.c b/usr.bin/ssh/packet.c index 006d2a03061..9ef0469892b 100644 --- a/usr.bin/ssh/packet.c +++ b/usr.bin/ssh/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.130 2006/03/25 18:56:55 deraadt Exp $ */ +/* $OpenBSD: packet.c,v 1.131 2006/03/30 09:58:16 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -49,7 +49,6 @@ #include "packet.h" #include "bufaux.h" #include "crc32.h" -#include "getput.h" #include "compress.h" #include "deattack.h" @@ -555,7 +554,7 @@ packet_send1(void) /* Add check bytes. */ checksum = ssh_crc32(buffer_ptr(&outgoing_packet), buffer_len(&outgoing_packet)); - PUT_32BIT(buf, checksum); + put_u32(buf, checksum); buffer_append(&outgoing_packet, buf, 4); #ifdef PACKET_DEBUG @@ -564,7 +563,7 @@ packet_send1(void) #endif /* Append to output. */ - PUT_32BIT(buf, len); + put_u32(buf, len); buffer_append(&output, buf, 4); cp = buffer_append_space(&output, buffer_len(&outgoing_packet)); cipher_crypt(&send_context, cp, buffer_ptr(&outgoing_packet), @@ -767,7 +766,7 @@ packet_send2_wrapped(void) /* packet_length includes payload, padding and padding length field */ packet_length = buffer_len(&outgoing_packet) - 4; cp = buffer_ptr(&outgoing_packet); - PUT_32BIT(cp, packet_length); + put_u32(cp, packet_length); cp[4] = padlen; DBG(debug("send: len %d (includes padlen %d)", packet_length+4, padlen)); @@ -965,7 +964,7 @@ packet_read_poll1(void) return SSH_MSG_NONE; /* Get length of incoming packet. */ cp = buffer_ptr(&input); - len = GET_32BIT(cp); + len = get_u32(cp); if (len < 1 + 2 + 2 || len > 256 * 1024) packet_disconnect("Bad packet length %u.", len); padded_len = (len + 8) & ~7; @@ -1013,7 +1012,7 @@ packet_read_poll1(void) len, buffer_len(&incoming_packet)); cp = (u_char *)buffer_ptr(&incoming_packet) + len - 4; - stored_checksum = GET_32BIT(cp); + stored_checksum = get_u32(cp); if (checksum != stored_checksum) packet_disconnect("Corrupted check bytes on input."); buffer_consume_end(&incoming_packet, 4); @@ -1062,7 +1061,7 @@ packet_read_poll2(u_int32_t *seqnr_p) cipher_crypt(&receive_context, cp, buffer_ptr(&input), block_size); cp = buffer_ptr(&incoming_packet); - packet_length = GET_32BIT(cp); + packet_length = get_u32(cp); if (packet_length < 1 + 4 || packet_length > 256 * 1024) { #ifdef PACKET_DEBUG buffer_dump(&incoming_packet); diff --git a/usr.bin/ssh/sftp-client.c b/usr.bin/ssh/sftp-client.c index 2a2b974947b..2f416547ed5 100644 --- a/usr.bin/ssh/sftp-client.c +++ b/usr.bin/ssh/sftp-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp-client.c,v 1.63 2006/03/25 13:17:02 djm Exp $ */ +/* $OpenBSD: sftp-client.c,v 1.64 2006/03/30 09:58:16 djm Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> * @@ -28,11 +28,11 @@ #include "buffer.h" #include "bufaux.h" -#include "getput.h" #include "xmalloc.h" #include "log.h" #include "atomicio.h" #include "progressmeter.h" +#include "misc.h" #include "sftp.h" #include "sftp-common.h" @@ -62,7 +62,7 @@ send_msg(int fd, Buffer *m) fatal("Outbound message too long %u", buffer_len(m)); /* Send length first */ - PUT_32BIT(mlen, buffer_len(m)); + put_u32(mlen, buffer_len(m)); if (atomicio(vwrite, fd, mlen, sizeof(mlen)) != sizeof(mlen)) fatal("Couldn't send packet: %s", strerror(errno)); diff --git a/usr.bin/ssh/sftp-server.c b/usr.bin/ssh/sftp-server.c index a1bb1de1cf2..6750f48b29a 100644 --- a/usr.bin/ssh/sftp-server.c +++ b/usr.bin/ssh/sftp-server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp-server.c,v 1.56 2006/03/25 13:17:02 djm Exp $ */ +/* $OpenBSD: sftp-server.c,v 1.57 2006/03/30 09:58:16 djm Exp $ */ /* * Copyright (c) 2000-2004 Markus Friedl. All rights reserved. * @@ -23,7 +23,6 @@ #include "buffer.h" #include "bufaux.h" -#include "getput.h" #include "log.h" #include "xmalloc.h" #include "misc.h" @@ -170,7 +169,7 @@ handle_to_string(int handle, char **stringp, int *hlenp) if (stringp == NULL || hlenp == NULL) return -1; *stringp = xmalloc(sizeof(int32_t)); - PUT_32BIT(*stringp, handle); + put_u32(*stringp, handle); *hlenp = sizeof(int32_t); return 0; } @@ -182,7 +181,7 @@ handle_from_string(const char *handle, u_int hlen) if (hlen != sizeof(int32_t)) return -1; - val = GET_32BIT(handle); + val = get_u32(handle); if (handle_is_ok(val, HANDLE_FILE) || handle_is_ok(val, HANDLE_DIR)) return val; @@ -930,7 +929,7 @@ process(void) if (buf_len < 5) return; /* Incomplete message. */ cp = buffer_ptr(&iqueue); - msg_len = GET_32BIT(cp); + msg_len = get_u32(cp); if (msg_len > SFTP_MAX_MSG_LENGTH) { error("bad message "); exit(11); diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c index da4d09b0d10..a774d7be041 100644 --- a/usr.bin/ssh/ssh-agent.c +++ b/usr.bin/ssh/ssh-agent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-agent.c,v 1.136 2006/03/28 01:53:43 deraadt Exp $ */ +/* $OpenBSD: ssh-agent.c,v 1.137 2006/03/30 09:58:16 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -52,7 +52,6 @@ #include "buffer.h" #include "bufaux.h" #include "xmalloc.h" -#include "getput.h" #include "key.h" #include "authfd.h" #include "compat.h" @@ -684,7 +683,7 @@ process_message(SocketEntry *e) if (buffer_len(&e->input) < 5) return; /* Incomplete message. */ cp = buffer_ptr(&e->input); - msg_len = GET_32BIT(cp); + msg_len = get_u32(cp); if (msg_len > 256 * 1024) { close_socket(e); return; |