diff options
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -37,7 +37,7 @@ | |||
37 | */ | 37 | */ |
38 | 38 | ||
39 | #include "includes.h" | 39 | #include "includes.h" |
40 | RCSID("$OpenBSD: packet.c,v 1.96 2002/06/23 21:10:02 deraadt Exp $"); | 40 | RCSID("$OpenBSD: packet.c,v 1.97 2002/07/04 08:12:15 deraadt Exp $"); |
41 | 41 | ||
42 | #include "xmalloc.h" | 42 | #include "xmalloc.h" |
43 | #include "buffer.h" | 43 | #include "buffer.h" |
@@ -134,6 +134,7 @@ void | |||
134 | packet_set_connection(int fd_in, int fd_out) | 134 | packet_set_connection(int fd_in, int fd_out) |
135 | { | 135 | { |
136 | Cipher *none = cipher_by_name("none"); | 136 | Cipher *none = cipher_by_name("none"); |
137 | |||
137 | if (none == NULL) | 138 | if (none == NULL) |
138 | fatal("packet_set_connection: cannot load cipher 'none'"); | 139 | fatal("packet_set_connection: cannot load cipher 'none'"); |
139 | connection_in = fd_in; | 140 | connection_in = fd_in; |
@@ -402,6 +403,7 @@ packet_set_encryption_key(const u_char *key, u_int keylen, | |||
402 | int number) | 403 | int number) |
403 | { | 404 | { |
404 | Cipher *cipher = cipher_by_number(number); | 405 | Cipher *cipher = cipher_by_number(number); |
406 | |||
405 | if (cipher == NULL) | 407 | if (cipher == NULL) |
406 | fatal("packet_set_encryption_key: unknown cipher number %d", number); | 408 | fatal("packet_set_encryption_key: unknown cipher number %d", number); |
407 | if (keylen < 20) | 409 | if (keylen < 20) |
@@ -443,6 +445,7 @@ void | |||
443 | packet_put_char(int value) | 445 | packet_put_char(int value) |
444 | { | 446 | { |
445 | char ch = value; | 447 | char ch = value; |
448 | |||
446 | buffer_append(&outgoing_packet, &ch, 1); | 449 | buffer_append(&outgoing_packet, &ch, 1); |
447 | } | 450 | } |
448 | void | 451 | void |
@@ -994,7 +997,8 @@ packet_read_poll2(u_int32_t *seqnr_p) | |||
994 | buffer_clear(&incoming_packet); | 997 | buffer_clear(&incoming_packet); |
995 | buffer_append(&incoming_packet, buffer_ptr(&compression_buffer), | 998 | buffer_append(&incoming_packet, buffer_ptr(&compression_buffer), |
996 | buffer_len(&compression_buffer)); | 999 | buffer_len(&compression_buffer)); |
997 | DBG(debug("input: len after de-compress %d", buffer_len(&incoming_packet))); | 1000 | DBG(debug("input: len after de-compress %d", |
1001 | buffer_len(&incoming_packet))); | ||
998 | } | 1002 | } |
999 | /* | 1003 | /* |
1000 | * get packet type, implies consume. | 1004 | * get packet type, implies consume. |
@@ -1102,6 +1106,7 @@ u_int | |||
1102 | packet_get_char(void) | 1106 | packet_get_char(void) |
1103 | { | 1107 | { |
1104 | char ch; | 1108 | char ch; |
1109 | |||
1105 | buffer_get(&incoming_packet, &ch, 1); | 1110 | buffer_get(&incoming_packet, &ch, 1); |
1106 | return (u_char) ch; | 1111 | return (u_char) ch; |
1107 | } | 1112 | } |
@@ -1135,6 +1140,7 @@ void * | |||
1135 | packet_get_raw(int *length_ptr) | 1140 | packet_get_raw(int *length_ptr) |
1136 | { | 1141 | { |
1137 | int bytes = buffer_len(&incoming_packet); | 1142 | int bytes = buffer_len(&incoming_packet); |
1143 | |||
1138 | if (length_ptr != NULL) | 1144 | if (length_ptr != NULL) |
1139 | *length_ptr = bytes; | 1145 | *length_ptr = bytes; |
1140 | return buffer_ptr(&incoming_packet); | 1146 | return buffer_ptr(&incoming_packet); |
@@ -1207,6 +1213,7 @@ packet_disconnect(const char *fmt,...) | |||
1207 | char buf[1024]; | 1213 | char buf[1024]; |
1208 | va_list args; | 1214 | va_list args; |
1209 | static int disconnecting = 0; | 1215 | static int disconnecting = 0; |
1216 | |||
1210 | if (disconnecting) /* Guard against recursive invocations. */ | 1217 | if (disconnecting) /* Guard against recursive invocations. */ |
1211 | fatal("packet_disconnect called recursively."); | 1218 | fatal("packet_disconnect called recursively."); |
1212 | disconnecting = 1; | 1219 | disconnecting = 1; |
@@ -1249,6 +1256,7 @@ void | |||
1249 | packet_write_poll(void) | 1256 | packet_write_poll(void) |
1250 | { | 1257 | { |
1251 | int len = buffer_len(&output); | 1258 | int len = buffer_len(&output); |
1259 | |||
1252 | if (len > 0) { | 1260 | if (len > 0) { |
1253 | len = write(connection_out, buffer_ptr(&output), len); | 1261 | len = write(connection_out, buffer_ptr(&output), len); |
1254 | if (len <= 0) { | 1262 | if (len <= 0) { |
@@ -1368,6 +1376,7 @@ int | |||
1368 | packet_set_maxsize(int s) | 1376 | packet_set_maxsize(int s) |
1369 | { | 1377 | { |
1370 | static int called = 0; | 1378 | static int called = 0; |
1379 | |||
1371 | if (called) { | 1380 | if (called) { |
1372 | log("packet_set_maxsize: called twice: old %d new %d", | 1381 | log("packet_set_maxsize: called twice: old %d new %d", |
1373 | max_packet_size, s); | 1382 | max_packet_size, s); |