diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | authfd.c | 8 | ||||
-rw-r--r-- | bufaux.c | 20 | ||||
-rw-r--r-- | deattack.c | 6 | ||||
-rw-r--r-- | gss-serv.c | 8 | ||||
-rw-r--r-- | mac.c | 6 | ||||
-rw-r--r-- | misc.c | 93 | ||||
-rw-r--r-- | misc.h | 24 | ||||
-rw-r--r-- | monitor_wrap.c | 8 | ||||
-rw-r--r-- | msg.c | 8 | ||||
-rw-r--r-- | packet.c | 15 | ||||
-rw-r--r-- | sftp-client.c | 6 | ||||
-rw-r--r-- | sftp-server.c | 9 | ||||
-rw-r--r-- | ssh-agent.c | 5 |
14 files changed, 166 insertions, 59 deletions
@@ -23,6 +23,13 @@ | |||
23 | - djm@cvs.openbsd.org 2006/03/30 09:41:25 | 23 | - djm@cvs.openbsd.org 2006/03/30 09:41:25 |
24 | [channels.c] | 24 | [channels.c] |
25 | ARGSUSED for dispatch table-driven functions | 25 | ARGSUSED for dispatch table-driven functions |
26 | - djm@cvs.openbsd.org 2006/03/30 09:58:16 | ||
27 | [authfd.c bufaux.c deattack.c gss-serv.c mac.c misc.c misc.h] | ||
28 | [monitor_wrap.c msg.c packet.c sftp-client.c sftp-server.c ssh-agent.c] | ||
29 | replace {GET,PUT}_XXBIT macros with functionally similar functions, | ||
30 | silencing a heap of lint warnings. also allows them to use | ||
31 | __bounded__ checking which can't be applied to macros; requested | ||
32 | by and feedback from deraadt@ | ||
26 | 33 | ||
27 | 20060326 | 34 | 20060326 |
28 | - OpenBSD CVS Sync | 35 | - OpenBSD CVS Sync |
@@ -4472,4 +4479,4 @@ | |||
4472 | - (djm) Trim deprecated options from INSTALL. Mention UsePAM | 4479 | - (djm) Trim deprecated options from INSTALL. Mention UsePAM |
4473 | - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu | 4480 | - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu |
4474 | 4481 | ||
4475 | $Id: ChangeLog,v 1.4294 2006/03/31 12:11:44 djm Exp $ | 4482 | $Id: ChangeLog,v 1.4295 2006/03/31 12:13:02 djm Exp $ |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: authfd.c,v 1.73 2006/03/25 18:29:35 deraadt Exp $ */ | 1 | /* $OpenBSD: authfd.c,v 1.74 2006/03/30 09:58:15 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -47,7 +47,6 @@ | |||
47 | #include "buffer.h" | 47 | #include "buffer.h" |
48 | #include "bufaux.h" | 48 | #include "bufaux.h" |
49 | #include "xmalloc.h" | 49 | #include "xmalloc.h" |
50 | #include "getput.h" | ||
51 | #include "key.h" | 50 | #include "key.h" |
52 | #include "authfd.h" | 51 | #include "authfd.h" |
53 | #include "cipher.h" | 52 | #include "cipher.h" |
@@ -55,6 +54,7 @@ | |||
55 | #include "compat.h" | 54 | #include "compat.h" |
56 | #include "log.h" | 55 | #include "log.h" |
57 | #include "atomicio.h" | 56 | #include "atomicio.h" |
57 | #include "misc.h" | ||
58 | 58 | ||
59 | static int agent_present = 0; | 59 | static int agent_present = 0; |
60 | 60 | ||
@@ -122,7 +122,7 @@ ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply | |||
122 | 122 | ||
123 | /* Get the length of the message, and format it in the buffer. */ | 123 | /* Get the length of the message, and format it in the buffer. */ |
124 | len = buffer_len(request); | 124 | len = buffer_len(request); |
125 | PUT_32BIT(buf, len); | 125 | put_u32(buf, len); |
126 | 126 | ||
127 | /* Send the length and then the packet to the agent. */ | 127 | /* Send the length and then the packet to the agent. */ |
128 | if (atomicio(vwrite, auth->fd, buf, 4) != 4 || | 128 | if (atomicio(vwrite, auth->fd, buf, 4) != 4 || |
@@ -141,7 +141,7 @@ ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply | |||
141 | } | 141 | } |
142 | 142 | ||
143 | /* Extract the length, and check it for sanity. */ | 143 | /* Extract the length, and check it for sanity. */ |
144 | len = GET_32BIT(buf); | 144 | len = get_u32(buf); |
145 | if (len > 256 * 1024) | 145 | if (len > 256 * 1024) |
146 | fatal("Authentication response too long: %u", len); | 146 | fatal("Authentication response too long: %u", len); |
147 | 147 | ||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bufaux.c,v 1.40 2006/03/25 18:56:54 deraadt Exp $ */ | 1 | /* $OpenBSD: bufaux.c,v 1.41 2006/03/30 09:58:15 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -42,8 +42,8 @@ | |||
42 | #include <openssl/bn.h> | 42 | #include <openssl/bn.h> |
43 | #include "bufaux.h" | 43 | #include "bufaux.h" |
44 | #include "xmalloc.h" | 44 | #include "xmalloc.h" |
45 | #include "getput.h" | ||
46 | #include "log.h" | 45 | #include "log.h" |
46 | #include "misc.h" | ||
47 | 47 | ||
48 | /* | 48 | /* |
49 | * Stores an BIGNUM in the buffer with a 2-byte msb first bit count, followed | 49 | * 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) | |||
68 | } | 68 | } |
69 | 69 | ||
70 | /* Store the number of bits in the buffer in two bytes, msb first. */ | 70 | /* Store the number of bits in the buffer in two bytes, msb first. */ |
71 | PUT_16BIT(msg, bits); | 71 | put_u16(msg, bits); |
72 | buffer_append(buffer, msg, 2); | 72 | buffer_append(buffer, msg, 2); |
73 | /* Store the binary data. */ | 73 | /* Store the binary data. */ |
74 | buffer_append(buffer, buf, oi); | 74 | buffer_append(buffer, buf, oi); |
@@ -100,7 +100,7 @@ buffer_get_bignum_ret(Buffer *buffer, BIGNUM *value) | |||
100 | error("buffer_get_bignum_ret: invalid length"); | 100 | error("buffer_get_bignum_ret: invalid length"); |
101 | return (-1); | 101 | return (-1); |
102 | } | 102 | } |
103 | bits = GET_16BIT(buf); | 103 | bits = get_u16(buf); |
104 | /* Compute the number of binary bytes that follow. */ | 104 | /* Compute the number of binary bytes that follow. */ |
105 | bytes = (bits + 7) / 8; | 105 | bytes = (bits + 7) / 8; |
106 | if (bytes > 8 * 1024) { | 106 | if (bytes > 8 * 1024) { |
@@ -219,7 +219,7 @@ buffer_get_short_ret(u_short *ret, Buffer *buffer) | |||
219 | 219 | ||
220 | if (buffer_get_ret(buffer, (char *) buf, 2) == -1) | 220 | if (buffer_get_ret(buffer, (char *) buf, 2) == -1) |
221 | return (-1); | 221 | return (-1); |
222 | *ret = GET_16BIT(buf); | 222 | *ret = get_u16(buf); |
223 | return (0); | 223 | return (0); |
224 | } | 224 | } |
225 | 225 | ||
@@ -241,7 +241,7 @@ buffer_get_int_ret(u_int *ret, Buffer *buffer) | |||
241 | 241 | ||
242 | if (buffer_get_ret(buffer, (char *) buf, 4) == -1) | 242 | if (buffer_get_ret(buffer, (char *) buf, 4) == -1) |
243 | return (-1); | 243 | return (-1); |
244 | *ret = GET_32BIT(buf); | 244 | *ret = get_u32(buf); |
245 | return (0); | 245 | return (0); |
246 | } | 246 | } |
247 | 247 | ||
@@ -263,7 +263,7 @@ buffer_get_int64_ret(u_int64_t *ret, Buffer *buffer) | |||
263 | 263 | ||
264 | if (buffer_get_ret(buffer, (char *) buf, 8) == -1) | 264 | if (buffer_get_ret(buffer, (char *) buf, 8) == -1) |
265 | return (-1); | 265 | return (-1); |
266 | *ret = GET_64BIT(buf); | 266 | *ret = get_u64(buf); |
267 | return (0); | 267 | return (0); |
268 | } | 268 | } |
269 | 269 | ||
@@ -286,7 +286,7 @@ buffer_put_short(Buffer *buffer, u_short value) | |||
286 | { | 286 | { |
287 | char buf[2]; | 287 | char buf[2]; |
288 | 288 | ||
289 | PUT_16BIT(buf, value); | 289 | put_u16(buf, value); |
290 | buffer_append(buffer, buf, 2); | 290 | buffer_append(buffer, buf, 2); |
291 | } | 291 | } |
292 | 292 | ||
@@ -295,7 +295,7 @@ buffer_put_int(Buffer *buffer, u_int value) | |||
295 | { | 295 | { |
296 | char buf[4]; | 296 | char buf[4]; |
297 | 297 | ||
298 | PUT_32BIT(buf, value); | 298 | put_u32(buf, value); |
299 | buffer_append(buffer, buf, 4); | 299 | buffer_append(buffer, buf, 4); |
300 | } | 300 | } |
301 | 301 | ||
@@ -304,7 +304,7 @@ buffer_put_int64(Buffer *buffer, u_int64_t value) | |||
304 | { | 304 | { |
305 | char buf[8]; | 305 | char buf[8]; |
306 | 306 | ||
307 | PUT_64BIT(buf, value); | 307 | put_u64(buf, value); |
308 | buffer_append(buffer, buf, 8); | 308 | buffer_append(buffer, buf, 8); |
309 | } | 309 | } |
310 | 310 | ||
diff --git a/deattack.c b/deattack.c index 2adf185e8..fa397e6e8 100644 --- a/deattack.c +++ b/deattack.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: deattack.c,v 1.26 2006/03/25 13:17:01 djm Exp $ */ | 1 | /* $OpenBSD: deattack.c,v 1.27 2006/03/30 09:58:15 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Cryptographic attack detector for ssh - source code | 3 | * Cryptographic attack detector for ssh - source code |
4 | * | 4 | * |
@@ -23,8 +23,8 @@ | |||
23 | #include "deattack.h" | 23 | #include "deattack.h" |
24 | #include "log.h" | 24 | #include "log.h" |
25 | #include "crc32.h" | 25 | #include "crc32.h" |
26 | #include "getput.h" | ||
27 | #include "xmalloc.h" | 26 | #include "xmalloc.h" |
27 | #include "misc.h" | ||
28 | 28 | ||
29 | /* SSH Constants */ | 29 | /* SSH Constants */ |
30 | #define SSH_MAXBLOCKS (32 * 1024) | 30 | #define SSH_MAXBLOCKS (32 * 1024) |
@@ -42,7 +42,7 @@ | |||
42 | 42 | ||
43 | 43 | ||
44 | /* Hash function (Input keys are cipher results) */ | 44 | /* Hash function (Input keys are cipher results) */ |
45 | #define HASH(x) GET_32BIT(x) | 45 | #define HASH(x) get_u32(x) |
46 | 46 | ||
47 | #define CMP(a, b) (memcmp(a, b, SSH_BLOCKSIZE)) | 47 | #define CMP(a, b) (memcmp(a, b, SSH_BLOCKSIZE)) |
48 | 48 | ||
diff --git a/gss-serv.c b/gss-serv.c index 53ec634e8..5e43ffe58 100644 --- a/gss-serv.c +++ b/gss-serv.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: gss-serv.c,v 1.16 2006/03/25 22:22:43 djm Exp $ */ | 1 | /* $OpenBSD: gss-serv.c,v 1.17 2006/03/30 09:58:15 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. | 4 | * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. |
@@ -35,7 +35,7 @@ | |||
35 | #include "session.h" | 35 | #include "session.h" |
36 | #include "servconf.h" | 36 | #include "servconf.h" |
37 | #include "xmalloc.h" | 37 | #include "xmalloc.h" |
38 | #include "getput.h" | 38 | #include "misc.h" |
39 | 39 | ||
40 | #include "ssh-gss.h" | 40 | #include "ssh-gss.h" |
41 | 41 | ||
@@ -153,7 +153,7 @@ ssh_gssapi_parse_ename(Gssctxt *ctx, gss_buffer_t ename, gss_buffer_t name) | |||
153 | * second without. | 153 | * second without. |
154 | */ | 154 | */ |
155 | 155 | ||
156 | oidl = GET_16BIT(tok+2); /* length including next two bytes */ | 156 | oidl = get_u16(tok+2); /* length including next two bytes */ |
157 | oidl = oidl-2; /* turn it into the _real_ length of the variable OID */ | 157 | oidl = oidl-2; /* turn it into the _real_ length of the variable OID */ |
158 | 158 | ||
159 | /* | 159 | /* |
@@ -170,7 +170,7 @@ ssh_gssapi_parse_ename(Gssctxt *ctx, gss_buffer_t ename, gss_buffer_t name) | |||
170 | if (ename->length < offset+4) | 170 | if (ename->length < offset+4) |
171 | return GSS_S_FAILURE; | 171 | return GSS_S_FAILURE; |
172 | 172 | ||
173 | name->length = GET_32BIT(tok+offset); | 173 | name->length = get_u32(tok+offset); |
174 | offset += 4; | 174 | offset += 4; |
175 | 175 | ||
176 | if (ename->length < offset+name->length) | 176 | if (ename->length < offset+name->length) |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: mac.c,v 1.9 2006/03/25 13:17:02 djm Exp $ */ | 1 | /* $OpenBSD: mac.c,v 1.10 2006/03/30 09:58:15 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2001 Markus Friedl. All rights reserved. |
4 | * | 4 | * |
@@ -28,11 +28,11 @@ | |||
28 | #include <openssl/hmac.h> | 28 | #include <openssl/hmac.h> |
29 | 29 | ||
30 | #include "xmalloc.h" | 30 | #include "xmalloc.h" |
31 | #include "getput.h" | ||
32 | #include "log.h" | 31 | #include "log.h" |
33 | #include "cipher.h" | 32 | #include "cipher.h" |
34 | #include "kex.h" | 33 | #include "kex.h" |
35 | #include "mac.h" | 34 | #include "mac.h" |
35 | #include "misc.h" | ||
36 | 36 | ||
37 | struct { | 37 | struct { |
38 | char *name; | 38 | char *name; |
@@ -83,7 +83,7 @@ mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen) | |||
83 | if (mac->mac_len > sizeof(m)) | 83 | if (mac->mac_len > sizeof(m)) |
84 | fatal("mac_compute: mac too long"); | 84 | fatal("mac_compute: mac too long"); |
85 | HMAC_Init(&c, mac->key, mac->key_len, mac->md); | 85 | HMAC_Init(&c, mac->key, mac->key_len, mac->md); |
86 | PUT_32BIT(b, seqno); | 86 | put_u32(b, seqno); |
87 | HMAC_Update(&c, b, sizeof(b)); | 87 | HMAC_Update(&c, b, sizeof(b)); |
88 | HMAC_Update(&c, data, datalen); | 88 | HMAC_Update(&c, data, datalen); |
89 | HMAC_Final(&c, m, NULL); | 89 | HMAC_Final(&c, m, NULL); |
@@ -1,7 +1,7 @@ | |||
1 | /* $OpenBSD: misc.c,v 1.51 2006/03/25 13:17:02 djm Exp $ */ | 1 | /* $OpenBSD: misc.c,v 1.52 2006/03/30 09:58:15 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. |
4 | * Copyright (c) 2005 Damien Miller. All rights reserved. | 4 | * Copyright (c) 2005,2006 Damien Miller. All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions |
@@ -691,17 +691,100 @@ sanitise_stdfd(void) | |||
691 | } | 691 | } |
692 | 692 | ||
693 | char * | 693 | char * |
694 | tohex(const u_char *d, u_int l) | 694 | tohex(const void *vp, size_t l) |
695 | { | 695 | { |
696 | const u_char *p = (const u_char *)vp; | ||
696 | char b[3], *r; | 697 | char b[3], *r; |
697 | u_int i, hl; | 698 | size_t i, hl; |
699 | |||
700 | if (l > 65536) | ||
701 | return xstrdup("tohex: length > 65536"); | ||
698 | 702 | ||
699 | hl = l * 2 + 1; | 703 | hl = l * 2 + 1; |
700 | r = xcalloc(1, hl); | 704 | r = xcalloc(1, hl); |
701 | for (i = 0; i < l; i++) { | 705 | for (i = 0; i < l; i++) { |
702 | snprintf(b, sizeof(b), "%02x", d[i]); | 706 | snprintf(b, sizeof(b), "%02x", p[i]); |
703 | strlcat(r, b, hl); | 707 | strlcat(r, b, hl); |
704 | } | 708 | } |
705 | return (r); | 709 | return (r); |
706 | } | 710 | } |
707 | 711 | ||
712 | u_int64_t | ||
713 | get_u64(const void *vp) | ||
714 | { | ||
715 | const u_char *p = (const u_char *)vp; | ||
716 | u_int64_t v; | ||
717 | |||
718 | v = (u_int64_t)p[0] << 56; | ||
719 | v |= (u_int64_t)p[1] << 48; | ||
720 | v |= (u_int64_t)p[2] << 40; | ||
721 | v |= (u_int64_t)p[3] << 32; | ||
722 | v |= (u_int64_t)p[4] << 24; | ||
723 | v |= (u_int64_t)p[5] << 16; | ||
724 | v |= (u_int64_t)p[6] << 8; | ||
725 | v |= (u_int64_t)p[7]; | ||
726 | |||
727 | return (v); | ||
728 | } | ||
729 | |||
730 | u_int32_t | ||
731 | get_u32(const void *vp) | ||
732 | { | ||
733 | const u_char *p = (const u_char *)vp; | ||
734 | u_int32_t v; | ||
735 | |||
736 | v = (u_int32_t)p[0] << 24; | ||
737 | v |= (u_int32_t)p[1] << 16; | ||
738 | v |= (u_int32_t)p[2] << 8; | ||
739 | v |= (u_int32_t)p[3]; | ||
740 | |||
741 | return (v); | ||
742 | } | ||
743 | |||
744 | u_int16_t | ||
745 | get_u16(const void *vp) | ||
746 | { | ||
747 | const u_char *p = (const u_char *)vp; | ||
748 | u_int16_t v; | ||
749 | |||
750 | v = (u_int16_t)p[0] << 8; | ||
751 | v |= (u_int16_t)p[1]; | ||
752 | |||
753 | return (v); | ||
754 | } | ||
755 | |||
756 | void | ||
757 | put_u64(void *vp, u_int64_t v) | ||
758 | { | ||
759 | u_char *p = (u_char *)vp; | ||
760 | |||
761 | p[0] = (u_char)(v >> 56) & 0xff; | ||
762 | p[1] = (u_char)(v >> 48) & 0xff; | ||
763 | p[2] = (u_char)(v >> 40) & 0xff; | ||
764 | p[3] = (u_char)(v >> 32) & 0xff; | ||
765 | p[4] = (u_char)(v >> 24) & 0xff; | ||
766 | p[5] = (u_char)(v >> 16) & 0xff; | ||
767 | p[6] = (u_char)(v >> 8) & 0xff; | ||
768 | p[7] = (u_char)v & 0xff; | ||
769 | } | ||
770 | |||
771 | void | ||
772 | put_u32(void *vp, u_int32_t v) | ||
773 | { | ||
774 | u_char *p = (u_char *)vp; | ||
775 | |||
776 | p[0] = (u_char)(v >> 24) & 0xff; | ||
777 | p[1] = (u_char)(v >> 16) & 0xff; | ||
778 | p[2] = (u_char)(v >> 8) & 0xff; | ||
779 | p[3] = (u_char)v & 0xff; | ||
780 | } | ||
781 | |||
782 | |||
783 | void | ||
784 | put_u16(void *vp, u_int16_t v) | ||
785 | { | ||
786 | u_char *p = (u_char *)vp; | ||
787 | |||
788 | p[0] = (u_char)(v >> 8) & 0xff; | ||
789 | p[1] = (u_char)v & 0xff; | ||
790 | } | ||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: misc.h,v 1.30 2006/03/25 22:22:43 djm Exp $ */ | 1 | /* $OpenBSD: misc.h,v 1.31 2006/03/30 09:58:15 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -12,6 +12,9 @@ | |||
12 | * called by a name other than "ssh" or "Secure Shell". | 12 | * called by a name other than "ssh" or "Secure Shell". |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #ifndef _MISC_H | ||
16 | #define _MISC_H | ||
17 | |||
15 | /* misc.c */ | 18 | /* misc.c */ |
16 | 19 | ||
17 | char *chop(char *); | 20 | char *chop(char *); |
@@ -27,7 +30,7 @@ char *colon(char *); | |||
27 | long convtime(const char *); | 30 | long convtime(const char *); |
28 | char *tilde_expand_filename(const char *, uid_t); | 31 | char *tilde_expand_filename(const char *, uid_t); |
29 | char *percent_expand(const char *, ...) __attribute__((__sentinel__)); | 32 | char *percent_expand(const char *, ...) __attribute__((__sentinel__)); |
30 | char *tohex(const u_char *, u_int); | 33 | char *tohex(const void *, size_t); |
31 | void sanitise_stdfd(void); | 34 | void sanitise_stdfd(void); |
32 | 35 | ||
33 | struct passwd *pwcopy(struct passwd *); | 36 | struct passwd *pwcopy(struct passwd *); |
@@ -67,3 +70,20 @@ int tun_open(int, int); | |||
67 | #define SSH_TUNID_ANY 0x7fffffff | 70 | #define SSH_TUNID_ANY 0x7fffffff |
68 | #define SSH_TUNID_ERR (SSH_TUNID_ANY - 1) | 71 | #define SSH_TUNID_ERR (SSH_TUNID_ANY - 1) |
69 | #define SSH_TUNID_MAX (SSH_TUNID_ANY - 2) | 72 | #define SSH_TUNID_MAX (SSH_TUNID_ANY - 2) |
73 | |||
74 | /* Functions to extract or store big-endian words of various sizes */ | ||
75 | u_int64_t get_u64(const void *) | ||
76 | __attribute__((__bounded__( __minbytes__, 1, 8))); | ||
77 | u_int32_t get_u32(const void *) | ||
78 | __attribute__((__bounded__( __minbytes__, 1, 4))); | ||
79 | u_int16_t get_u16(const void *) | ||
80 | __attribute__((__bounded__( __minbytes__, 1, 2))); | ||
81 | void put_u64(void *, u_int64_t) | ||
82 | __attribute__((__bounded__( __minbytes__, 1, 8))); | ||
83 | void put_u32(void *, u_int32_t) | ||
84 | __attribute__((__bounded__( __minbytes__, 1, 4))); | ||
85 | void put_u16(void *, u_int16_t) | ||
86 | __attribute__((__bounded__( __minbytes__, 1, 2))); | ||
87 | |||
88 | #endif /* _MISC_H */ | ||
89 | |||
diff --git a/monitor_wrap.c b/monitor_wrap.c index f2fbd99ee..8cfc8cc08 100644 --- a/monitor_wrap.c +++ b/monitor_wrap.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: monitor_wrap.c,v 1.44 2006/03/25 13:17:02 djm Exp $ */ | 1 | /* $OpenBSD: monitor_wrap.c,v 1.45 2006/03/30 09:58:15 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright 2002 Niels Provos <provos@citi.umich.edu> | 3 | * Copyright 2002 Niels Provos <provos@citi.umich.edu> |
4 | * Copyright 2002 Markus Friedl <markus@openbsd.org> | 4 | * Copyright 2002 Markus Friedl <markus@openbsd.org> |
@@ -52,7 +52,7 @@ | |||
52 | #include "xmalloc.h" | 52 | #include "xmalloc.h" |
53 | #include "atomicio.h" | 53 | #include "atomicio.h" |
54 | #include "monitor_fdpass.h" | 54 | #include "monitor_fdpass.h" |
55 | #include "getput.h" | 55 | #include "misc.h" |
56 | #include "servconf.h" | 56 | #include "servconf.h" |
57 | 57 | ||
58 | #include "auth.h" | 58 | #include "auth.h" |
@@ -91,7 +91,7 @@ mm_request_send(int sock, enum monitor_reqtype type, Buffer *m) | |||
91 | 91 | ||
92 | debug3("%s entering: type %d", __func__, type); | 92 | debug3("%s entering: type %d", __func__, type); |
93 | 93 | ||
94 | PUT_32BIT(buf, mlen + 1); | 94 | put_u32(buf, mlen + 1); |
95 | buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */ | 95 | buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */ |
96 | if (atomicio(vwrite, sock, buf, sizeof(buf)) != sizeof(buf)) | 96 | if (atomicio(vwrite, sock, buf, sizeof(buf)) != sizeof(buf)) |
97 | fatal("%s: write: %s", __func__, strerror(errno)); | 97 | fatal("%s: write: %s", __func__, strerror(errno)); |
@@ -112,7 +112,7 @@ mm_request_receive(int sock, Buffer *m) | |||
112 | cleanup_exit(255); | 112 | cleanup_exit(255); |
113 | fatal("%s: read: %s", __func__, strerror(errno)); | 113 | fatal("%s: read: %s", __func__, strerror(errno)); |
114 | } | 114 | } |
115 | msg_len = GET_32BIT(buf); | 115 | msg_len = get_u32(buf); |
116 | if (msg_len > 256 * 1024) | 116 | if (msg_len > 256 * 1024) |
117 | fatal("%s: read: bad msg_len %d", __func__, msg_len); | 117 | fatal("%s: read: bad msg_len %d", __func__, msg_len); |
118 | buffer_clear(m); | 118 | buffer_clear(m); |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: msg.c,v 1.10 2006/03/25 13:17:02 djm Exp $ */ | 1 | /* $OpenBSD: msg.c,v 1.11 2006/03/30 09:58:15 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2002 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2002 Markus Friedl. All rights reserved. |
4 | * | 4 | * |
@@ -25,10 +25,10 @@ | |||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | 26 | ||
27 | #include "buffer.h" | 27 | #include "buffer.h" |
28 | #include "getput.h" | ||
29 | #include "log.h" | 28 | #include "log.h" |
30 | #include "atomicio.h" | 29 | #include "atomicio.h" |
31 | #include "msg.h" | 30 | #include "msg.h" |
31 | #include "misc.h" | ||
32 | 32 | ||
33 | int | 33 | int |
34 | ssh_msg_send(int fd, u_char type, Buffer *m) | 34 | ssh_msg_send(int fd, u_char type, Buffer *m) |
@@ -38,7 +38,7 @@ ssh_msg_send(int fd, u_char type, Buffer *m) | |||
38 | 38 | ||
39 | debug3("ssh_msg_send: type %u", (unsigned int)type & 0xff); | 39 | debug3("ssh_msg_send: type %u", (unsigned int)type & 0xff); |
40 | 40 | ||
41 | PUT_32BIT(buf, mlen + 1); | 41 | put_u32(buf, mlen + 1); |
42 | buf[4] = type; /* 1st byte of payload is mesg-type */ | 42 | buf[4] = type; /* 1st byte of payload is mesg-type */ |
43 | if (atomicio(vwrite, fd, buf, sizeof(buf)) != sizeof(buf)) { | 43 | if (atomicio(vwrite, fd, buf, sizeof(buf)) != sizeof(buf)) { |
44 | error("ssh_msg_send: write"); | 44 | error("ssh_msg_send: write"); |
@@ -64,7 +64,7 @@ ssh_msg_recv(int fd, Buffer *m) | |||
64 | error("ssh_msg_recv: read: header"); | 64 | error("ssh_msg_recv: read: header"); |
65 | return (-1); | 65 | return (-1); |
66 | } | 66 | } |
67 | msg_len = GET_32BIT(buf); | 67 | msg_len = get_u32(buf); |
68 | if (msg_len > 256 * 1024) { | 68 | if (msg_len > 256 * 1024) { |
69 | error("ssh_msg_recv: read: bad msg_len %u", msg_len); | 69 | error("ssh_msg_recv: read: bad msg_len %u", msg_len); |
70 | return (-1); | 70 | return (-1); |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: packet.c,v 1.130 2006/03/25 18:56:55 deraadt Exp $ */ | 1 | /* $OpenBSD: packet.c,v 1.131 2006/03/30 09:58:16 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -48,7 +48,6 @@ | |||
48 | #include "packet.h" | 48 | #include "packet.h" |
49 | #include "bufaux.h" | 49 | #include "bufaux.h" |
50 | #include "crc32.h" | 50 | #include "crc32.h" |
51 | #include "getput.h" | ||
52 | 51 | ||
53 | #include "compress.h" | 52 | #include "compress.h" |
54 | #include "deattack.h" | 53 | #include "deattack.h" |
@@ -559,7 +558,7 @@ packet_send1(void) | |||
559 | /* Add check bytes. */ | 558 | /* Add check bytes. */ |
560 | checksum = ssh_crc32(buffer_ptr(&outgoing_packet), | 559 | checksum = ssh_crc32(buffer_ptr(&outgoing_packet), |
561 | buffer_len(&outgoing_packet)); | 560 | buffer_len(&outgoing_packet)); |
562 | PUT_32BIT(buf, checksum); | 561 | put_u32(buf, checksum); |
563 | buffer_append(&outgoing_packet, buf, 4); | 562 | buffer_append(&outgoing_packet, buf, 4); |
564 | 563 | ||
565 | #ifdef PACKET_DEBUG | 564 | #ifdef PACKET_DEBUG |
@@ -568,7 +567,7 @@ packet_send1(void) | |||
568 | #endif | 567 | #endif |
569 | 568 | ||
570 | /* Append to output. */ | 569 | /* Append to output. */ |
571 | PUT_32BIT(buf, len); | 570 | put_u32(buf, len); |
572 | buffer_append(&output, buf, 4); | 571 | buffer_append(&output, buf, 4); |
573 | cp = buffer_append_space(&output, buffer_len(&outgoing_packet)); | 572 | cp = buffer_append_space(&output, buffer_len(&outgoing_packet)); |
574 | cipher_crypt(&send_context, cp, buffer_ptr(&outgoing_packet), | 573 | cipher_crypt(&send_context, cp, buffer_ptr(&outgoing_packet), |
@@ -771,7 +770,7 @@ packet_send2_wrapped(void) | |||
771 | /* packet_length includes payload, padding and padding length field */ | 770 | /* packet_length includes payload, padding and padding length field */ |
772 | packet_length = buffer_len(&outgoing_packet) - 4; | 771 | packet_length = buffer_len(&outgoing_packet) - 4; |
773 | cp = buffer_ptr(&outgoing_packet); | 772 | cp = buffer_ptr(&outgoing_packet); |
774 | PUT_32BIT(cp, packet_length); | 773 | put_u32(cp, packet_length); |
775 | cp[4] = padlen; | 774 | cp[4] = padlen; |
776 | DBG(debug("send: len %d (includes padlen %d)", packet_length+4, padlen)); | 775 | DBG(debug("send: len %d (includes padlen %d)", packet_length+4, padlen)); |
777 | 776 | ||
@@ -969,7 +968,7 @@ packet_read_poll1(void) | |||
969 | return SSH_MSG_NONE; | 968 | return SSH_MSG_NONE; |
970 | /* Get length of incoming packet. */ | 969 | /* Get length of incoming packet. */ |
971 | cp = buffer_ptr(&input); | 970 | cp = buffer_ptr(&input); |
972 | len = GET_32BIT(cp); | 971 | len = get_u32(cp); |
973 | if (len < 1 + 2 + 2 || len > 256 * 1024) | 972 | if (len < 1 + 2 + 2 || len > 256 * 1024) |
974 | packet_disconnect("Bad packet length %u.", len); | 973 | packet_disconnect("Bad packet length %u.", len); |
975 | padded_len = (len + 8) & ~7; | 974 | padded_len = (len + 8) & ~7; |
@@ -1017,7 +1016,7 @@ packet_read_poll1(void) | |||
1017 | len, buffer_len(&incoming_packet)); | 1016 | len, buffer_len(&incoming_packet)); |
1018 | 1017 | ||
1019 | cp = (u_char *)buffer_ptr(&incoming_packet) + len - 4; | 1018 | cp = (u_char *)buffer_ptr(&incoming_packet) + len - 4; |
1020 | stored_checksum = GET_32BIT(cp); | 1019 | stored_checksum = get_u32(cp); |
1021 | if (checksum != stored_checksum) | 1020 | if (checksum != stored_checksum) |
1022 | packet_disconnect("Corrupted check bytes on input."); | 1021 | packet_disconnect("Corrupted check bytes on input."); |
1023 | buffer_consume_end(&incoming_packet, 4); | 1022 | buffer_consume_end(&incoming_packet, 4); |
@@ -1066,7 +1065,7 @@ packet_read_poll2(u_int32_t *seqnr_p) | |||
1066 | cipher_crypt(&receive_context, cp, buffer_ptr(&input), | 1065 | cipher_crypt(&receive_context, cp, buffer_ptr(&input), |
1067 | block_size); | 1066 | block_size); |
1068 | cp = buffer_ptr(&incoming_packet); | 1067 | cp = buffer_ptr(&incoming_packet); |
1069 | packet_length = GET_32BIT(cp); | 1068 | packet_length = get_u32(cp); |
1070 | if (packet_length < 1 + 4 || packet_length > 256 * 1024) { | 1069 | if (packet_length < 1 + 4 || packet_length > 256 * 1024) { |
1071 | #ifdef PACKET_DEBUG | 1070 | #ifdef PACKET_DEBUG |
1072 | buffer_dump(&incoming_packet); | 1071 | buffer_dump(&incoming_packet); |
diff --git a/sftp-client.c b/sftp-client.c index 5788aa6ad..c71c66f33 100644 --- a/sftp-client.c +++ b/sftp-client.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sftp-client.c,v 1.63 2006/03/25 13:17:02 djm Exp $ */ | 1 | /* $OpenBSD: sftp-client.c,v 1.64 2006/03/30 09:58:16 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> | 3 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> |
4 | * | 4 | * |
@@ -32,11 +32,11 @@ | |||
32 | 32 | ||
33 | #include "buffer.h" | 33 | #include "buffer.h" |
34 | #include "bufaux.h" | 34 | #include "bufaux.h" |
35 | #include "getput.h" | ||
36 | #include "xmalloc.h" | 35 | #include "xmalloc.h" |
37 | #include "log.h" | 36 | #include "log.h" |
38 | #include "atomicio.h" | 37 | #include "atomicio.h" |
39 | #include "progressmeter.h" | 38 | #include "progressmeter.h" |
39 | #include "misc.h" | ||
40 | 40 | ||
41 | #include "sftp.h" | 41 | #include "sftp.h" |
42 | #include "sftp-common.h" | 42 | #include "sftp-common.h" |
@@ -66,7 +66,7 @@ send_msg(int fd, Buffer *m) | |||
66 | fatal("Outbound message too long %u", buffer_len(m)); | 66 | fatal("Outbound message too long %u", buffer_len(m)); |
67 | 67 | ||
68 | /* Send length first */ | 68 | /* Send length first */ |
69 | PUT_32BIT(mlen, buffer_len(m)); | 69 | put_u32(mlen, buffer_len(m)); |
70 | if (atomicio(vwrite, fd, mlen, sizeof(mlen)) != sizeof(mlen)) | 70 | if (atomicio(vwrite, fd, mlen, sizeof(mlen)) != sizeof(mlen)) |
71 | fatal("Couldn't send packet: %s", strerror(errno)); | 71 | fatal("Couldn't send packet: %s", strerror(errno)); |
72 | 72 | ||
diff --git a/sftp-server.c b/sftp-server.c index e58aa59c8..e842341cb 100644 --- a/sftp-server.c +++ b/sftp-server.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sftp-server.c,v 1.56 2006/03/25 13:17:02 djm Exp $ */ | 1 | /* $OpenBSD: sftp-server.c,v 1.57 2006/03/30 09:58:16 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2000-2004 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2000-2004 Markus Friedl. All rights reserved. |
4 | * | 4 | * |
@@ -23,7 +23,6 @@ | |||
23 | 23 | ||
24 | #include "buffer.h" | 24 | #include "buffer.h" |
25 | #include "bufaux.h" | 25 | #include "bufaux.h" |
26 | #include "getput.h" | ||
27 | #include "log.h" | 26 | #include "log.h" |
28 | #include "xmalloc.h" | 27 | #include "xmalloc.h" |
29 | #include "misc.h" | 28 | #include "misc.h" |
@@ -172,7 +171,7 @@ handle_to_string(int handle, char **stringp, int *hlenp) | |||
172 | if (stringp == NULL || hlenp == NULL) | 171 | if (stringp == NULL || hlenp == NULL) |
173 | return -1; | 172 | return -1; |
174 | *stringp = xmalloc(sizeof(int32_t)); | 173 | *stringp = xmalloc(sizeof(int32_t)); |
175 | PUT_32BIT(*stringp, handle); | 174 | put_u32(*stringp, handle); |
176 | *hlenp = sizeof(int32_t); | 175 | *hlenp = sizeof(int32_t); |
177 | return 0; | 176 | return 0; |
178 | } | 177 | } |
@@ -184,7 +183,7 @@ handle_from_string(const char *handle, u_int hlen) | |||
184 | 183 | ||
185 | if (hlen != sizeof(int32_t)) | 184 | if (hlen != sizeof(int32_t)) |
186 | return -1; | 185 | return -1; |
187 | val = GET_32BIT(handle); | 186 | val = get_u32(handle); |
188 | if (handle_is_ok(val, HANDLE_FILE) || | 187 | if (handle_is_ok(val, HANDLE_FILE) || |
189 | handle_is_ok(val, HANDLE_DIR)) | 188 | handle_is_ok(val, HANDLE_DIR)) |
190 | return val; | 189 | return val; |
@@ -950,7 +949,7 @@ process(void) | |||
950 | if (buf_len < 5) | 949 | if (buf_len < 5) |
951 | return; /* Incomplete message. */ | 950 | return; /* Incomplete message. */ |
952 | cp = buffer_ptr(&iqueue); | 951 | cp = buffer_ptr(&iqueue); |
953 | msg_len = GET_32BIT(cp); | 952 | msg_len = get_u32(cp); |
954 | if (msg_len > SFTP_MAX_MSG_LENGTH) { | 953 | if (msg_len > SFTP_MAX_MSG_LENGTH) { |
955 | error("bad message "); | 954 | error("bad message "); |
956 | exit(11); | 955 | exit(11); |
diff --git a/ssh-agent.c b/ssh-agent.c index 162760ac2..681c30235 100644 --- a/ssh-agent.c +++ b/ssh-agent.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-agent.c,v 1.136 2006/03/28 01:53:43 deraadt Exp $ */ | 1 | /* $OpenBSD: ssh-agent.c,v 1.137 2006/03/30 09:58:16 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -56,7 +56,6 @@ | |||
56 | #include "buffer.h" | 56 | #include "buffer.h" |
57 | #include "bufaux.h" | 57 | #include "bufaux.h" |
58 | #include "xmalloc.h" | 58 | #include "xmalloc.h" |
59 | #include "getput.h" | ||
60 | #include "key.h" | 59 | #include "key.h" |
61 | #include "authfd.h" | 60 | #include "authfd.h" |
62 | #include "compat.h" | 61 | #include "compat.h" |
@@ -692,7 +691,7 @@ process_message(SocketEntry *e) | |||
692 | if (buffer_len(&e->input) < 5) | 691 | if (buffer_len(&e->input) < 5) |
693 | return; /* Incomplete message. */ | 692 | return; /* Incomplete message. */ |
694 | cp = buffer_ptr(&e->input); | 693 | cp = buffer_ptr(&e->input); |
695 | msg_len = GET_32BIT(cp); | 694 | msg_len = get_u32(cp); |
696 | if (msg_len > 256 * 1024) { | 695 | if (msg_len > 256 * 1024) { |
697 | close_socket(e); | 696 | close_socket(e); |
698 | return; | 697 | return; |