=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/packet.c,v retrieving revision 1.102.2.2 retrieving revision 1.103 diff -u -r1.102.2.2 -r1.103 --- src/usr.bin/ssh/packet.c 2004/03/04 18:18:16 1.102.2.2 +++ src/usr.bin/ssh/packet.c 2003/04/01 10:10:23 1.103 @@ -37,7 +37,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: packet.c,v 1.102.2.2 2004/03/04 18:18:16 brad Exp $"); +RCSID("$OpenBSD: packet.c,v 1.103 2003/04/01 10:10:23 markus Exp $"); #include @@ -108,7 +108,7 @@ static int packet_compression = 0; /* default maximum packet size */ -u_int max_packet_size = 32768; +int max_packet_size = 32768; /* Flag indicating whether this module has been initialized. */ static int initialized = 0; @@ -165,6 +165,8 @@ buffer_init(&incoming_packet); TAILQ_INIT(&outgoing); } + /* Kludge: arrange the close function to be called from fatal(). */ + fatal_add_cleanup((void (*) (void *)) packet_close, NULL); } /* Returns 1 if remote host is connected via socket, 0 if not. */ @@ -263,7 +265,7 @@ cipher_set_keyiv(cc, dat); } int -packet_get_ssh1_cipher(void) +packet_get_ssh1_cipher() { return (cipher_get_number(receive_context.cipher)); } @@ -628,14 +630,7 @@ buffer_compress_init_recv(); comp->enabled = 1; } - /* - * The 2^(blocksize*2) limit is too expensive for 3DES, - * blowfish, etc, so enforce a 1GB limit for small blocksizes. - */ - if (enc->block_size >= 16) - *max_blocks = (u_int64_t)1 << (enc->block_size*2); - else - *max_blocks = ((u_int64_t)1 << 30) / enc->block_size; + *max_blocks = ((u_int64_t)1 << (enc->block_size*2)); if (rekey_limit) *max_blocks = MIN(*max_blocks, rekey_limit / enc->block_size); } @@ -744,7 +739,7 @@ #endif /* increment sequence number for outgoing packets */ if (++p_send.seqnr == 0) - logit("outgoing seqnr wraps around"); + log("outgoing seqnr wraps around"); if (++p_send.packets == 0) if (!(datafellows & SSH_BUG_NOREKEY)) fatal("XXX too many packets with same key"); @@ -862,8 +857,8 @@ /* Read data from the socket. */ len = read(connection_in, buf, sizeof(buf)); if (len == 0) { - logit("Connection closed by %.200s", get_remote_ipaddr()); - cleanup_exit(255); + log("Connection closed by %.200s", get_remote_ipaddr()); + fatal_cleanup(); } if (len < 0) fatal("Read from socket failed: %.100s", strerror(errno)); @@ -1013,9 +1008,7 @@ cp = buffer_ptr(&incoming_packet); packet_length = GET_32BIT(cp); if (packet_length < 1 + 4 || packet_length > 256 * 1024) { -#ifdef PACKET_DEBUG buffer_dump(&incoming_packet); -#endif packet_disconnect("Bad packet length %u.", packet_length); } DBG(debug("input: packet len %u", packet_length+4)); @@ -1057,7 +1050,7 @@ if (seqnr_p != NULL) *seqnr_p = p_read.seqnr; if (++p_read.seqnr == 0) - logit("incoming seqnr wraps around"); + log("incoming seqnr wraps around"); if (++p_read.packets == 0) if (!(datafellows & SSH_BUG_NOREKEY)) fatal("XXX too many packets with same key"); @@ -1126,10 +1119,10 @@ case SSH2_MSG_DISCONNECT: reason = packet_get_int(); msg = packet_get_string(NULL); - logit("Received disconnect from %s: %u: %.400s", + log("Received disconnect from %s: %u: %.400s", get_remote_ipaddr(), reason, msg); xfree(msg); - cleanup_exit(255); + fatal_cleanup(); break; case SSH2_MSG_UNIMPLEMENTED: seqnr = packet_get_int(); @@ -1152,9 +1145,9 @@ break; case SSH_MSG_DISCONNECT: msg = packet_get_string(NULL); - logit("Received disconnect from %s: %.400s", + log("Received disconnect from %s: %.400s", get_remote_ipaddr(), msg); - cleanup_exit(255); + fatal_cleanup(); xfree(msg); break; default: @@ -1311,7 +1304,7 @@ va_end(args); /* Display the error locally */ - logit("Disconnecting: %.100s", buf); + log("Disconnecting: %.100s", buf); /* Send the disconnect message to the other side, and wait for it to get sent. */ if (compat20) { @@ -1331,7 +1324,8 @@ /* Close the connection. */ packet_close(); - cleanup_exit(255); + + fatal_cleanup(); } /* Checks if there is any buffered output, and tries to write some of the output. */ @@ -1441,18 +1435,18 @@ return interactive_mode; } -u_int -packet_set_maxsize(u_int s) +int +packet_set_maxsize(int s) { static int called = 0; if (called) { - logit("packet_set_maxsize: called twice: old %d new %d", + log("packet_set_maxsize: called twice: old %d new %d", max_packet_size, s); return -1; } if (s < 4 * 1024 || s > 1024 * 1024) { - logit("packet_set_maxsize: bad size %d", s); + log("packet_set_maxsize: bad size %d", s); return -1; } called = 1;