X-Git-Url: http://andersk.mit.edu/gitweb/openssh.git/blobdiff_plain/20b279e661f7b67a8623675893802eeb205663f5..20905a8e36d66feab55b4644ba1207c99221ab6c:/packet.c?ds=sidebyside diff --git a/packet.c b/packet.c index 065f8a52..5d97c379 100644 --- a/packet.c +++ b/packet.c @@ -37,7 +37,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: packet.c,v 1.80 2001/12/28 13:57:33 markus Exp $"); +RCSID("$OpenBSD: packet.c,v 1.83 2001/12/29 21:56:01 stevesk Exp $"); #include "xmalloc.h" #include "buffer.h" @@ -399,7 +399,7 @@ packet_send1(void) buffer_consume(&outgoing_packet, 8 - padding); /* Add check bytes. */ - checksum = ssh_crc32((u_char *) buffer_ptr(&outgoing_packet), + checksum = ssh_crc32(buffer_ptr(&outgoing_packet), buffer_len(&outgoing_packet)); PUT_32BIT(buf, checksum); buffer_append(&outgoing_packet, buf, 4); @@ -505,7 +505,7 @@ packet_send2(void) } block_size = enc ? enc->cipher->block_size : 8; - ucp = (u_char *) buffer_ptr(&outgoing_packet); + ucp = buffer_ptr(&outgoing_packet); type = ucp[5]; #ifdef PACKET_DEBUG @@ -561,7 +561,7 @@ packet_send2(void) } /* packet_length includes payload, padding and padding length field */ packet_length = buffer_len(&outgoing_packet) - 4; - ucp = (u_char *)buffer_ptr(&outgoing_packet); + ucp = buffer_ptr(&outgoing_packet); PUT_32BIT(ucp, packet_length); ucp[4] = padlen; DBG(debug("send: len %d (includes padlen %d)", packet_length+4, padlen)); @@ -569,7 +569,7 @@ packet_send2(void) /* compute MAC over seqnr and packet(length fields, payload, padding) */ if (mac && mac->enabled) { macbuf = mac_compute(mac, seqnr, - (u_char *) buffer_ptr(&outgoing_packet), + buffer_ptr(&outgoing_packet), buffer_len(&outgoing_packet)); DBG(debug("done calc MAC out #%d", seqnr)); } @@ -610,7 +610,7 @@ packet_send(void) */ int -packet_read_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) +packet_read_seqnr(u_int32_t *seqnr_p) { int type, len; fd_set *setp; @@ -626,7 +626,7 @@ packet_read_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) /* Stay in the loop until we have received a complete packet. */ for (;;) { /* Try to read a packet from the buffer. */ - type = packet_read_poll_seqnr(payload_len_ptr, seqnr_p); + type = packet_read_poll_seqnr(seqnr_p); if (!compat20 && ( type == SSH_SMSG_SUCCESS || type == SSH_SMSG_FAILURE @@ -666,9 +666,9 @@ packet_read_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) } int -packet_read(int *payload_len_ptr) +packet_read(void) { - return packet_read_seqnr(payload_len_ptr, NULL); + return packet_read_seqnr(NULL); } /* @@ -677,11 +677,11 @@ packet_read(int *payload_len_ptr) */ void -packet_read_expect(int *payload_len_ptr, int expected_type) +packet_read_expect(int expected_type) { int type; - type = packet_read(payload_len_ptr); + type = packet_read(); if (type != expected_type) packet_disconnect("Protocol error: expected packet type %d, got %d", expected_type, type); @@ -694,16 +694,10 @@ packet_read_expect(int *payload_len_ptr, int expected_type) * SSH_MSG_DISCONNECT is handled specially here. Also, * SSH_MSG_IGNORE messages are skipped by this function and are never returned * to higher levels. - * - * The returned payload_len does include space consumed by: - * Packet length - * Padding - * Packet type - * Check bytes */ static int -packet_read_poll1(int *payload_len_ptr) +packet_read_poll1(void) { u_int len, padded_len; u_char *ucp, type; @@ -714,7 +708,7 @@ packet_read_poll1(int *payload_len_ptr) if (buffer_len(&input) < 4 + 8) return SSH_MSG_NONE; /* Get length of incoming packet. */ - ucp = (u_char *) buffer_ptr(&input); + ucp = buffer_ptr(&input); len = GET_32BIT(ucp); if (len < 1 + 2 + 2 || len > 256 * 1024) packet_disconnect("Bad packet length %d.", len); @@ -751,7 +745,7 @@ packet_read_poll1(int *payload_len_ptr) #endif /* Compute packet checksum. */ - checksum = ssh_crc32((u_char *) buffer_ptr(&incoming_packet), + checksum = ssh_crc32(buffer_ptr(&incoming_packet), buffer_len(&incoming_packet) - 4); /* Skip padding. */ @@ -762,7 +756,7 @@ packet_read_poll1(int *payload_len_ptr) packet_disconnect("packet_read_poll1: len %d != buffer_len %d.", len, buffer_len(&incoming_packet)); - ucp = (u_char *) buffer_ptr(&incoming_packet) + len - 4; + ucp = (u_char *)buffer_ptr(&incoming_packet) + len - 4; stored_checksum = GET_32BIT(ucp); if (checksum != stored_checksum) packet_disconnect("Corrupted check bytes on input."); @@ -776,12 +770,11 @@ packet_read_poll1(int *payload_len_ptr) buffer_len(&compression_buffer)); } type = buffer_get_char(&incoming_packet); - *payload_len_ptr = buffer_len(&incoming_packet); return type; } static int -packet_read_poll2(int *payload_len_ptr, u_int32_t *seqnr_p) +packet_read_poll2(u_int32_t *seqnr_p) { static u_int32_t seqnr = 0; static u_int packet_length = 0; @@ -812,7 +805,7 @@ packet_read_poll2(int *payload_len_ptr, u_int32_t *seqnr_p) 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); + ucp = buffer_ptr(&incoming_packet); packet_length = GET_32BIT(ucp); if (packet_length < 1 + 4 || packet_length > 256 * 1024) { buffer_dump(&incoming_packet); @@ -847,7 +840,7 @@ packet_read_poll2(int *payload_len_ptr, u_int32_t *seqnr_p) */ if (mac && mac->enabled) { macbuf = mac_compute(mac, seqnr, - (u_char *) buffer_ptr(&incoming_packet), + buffer_ptr(&incoming_packet), buffer_len(&incoming_packet)); if (memcmp(macbuf, buffer_ptr(&input), mac->mac_len) != 0) packet_disconnect("Corrupted MAC on input."); @@ -887,7 +880,6 @@ packet_read_poll2(int *payload_len_ptr, u_int32_t *seqnr_p) type = buffer_get_char(&incoming_packet); if (type == SSH2_MSG_NEWKEYS) set_newkeys(MODE_IN); - *payload_len_ptr = buffer_len(&incoming_packet); #ifdef PACKET_DEBUG fprintf(stderr, "read/plain[%d]:\r\n", type); buffer_dump(&incoming_packet); @@ -898,7 +890,7 @@ packet_read_poll2(int *payload_len_ptr, u_int32_t *seqnr_p) } int -packet_read_poll_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) +packet_read_poll_seqnr(u_int32_t *seqnr_p) { int reason; u_char type; @@ -906,7 +898,7 @@ packet_read_poll_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) for (;;) { if (compat20) { - type = packet_read_poll2(payload_len_ptr, seqnr_p); + type = packet_read_poll2(seqnr_p); if (type) DBG(debug("received packet type %d", type)); switch (type) { @@ -933,7 +925,7 @@ packet_read_poll_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) break; } } else { - type = packet_read_poll1(payload_len_ptr); + type = packet_read_poll1(); switch (type) { case SSH_MSG_IGNORE: break; @@ -960,9 +952,9 @@ packet_read_poll_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) } int -packet_read_poll(int *payload_len_ptr) +packet_read_poll(void) { - return packet_read_poll_seqnr(payload_len_ptr, NULL); + return packet_read_poll_seqnr(NULL); } /* @@ -1002,13 +994,13 @@ packet_get_int(void) void packet_get_bignum(BIGNUM * value) { - (void)buffer_get_bignum(&incoming_packet, value); + buffer_get_bignum(&incoming_packet, value); } void packet_get_bignum2(BIGNUM * value) { - (void)buffer_get_bignum2(&incoming_packet, value); + buffer_get_bignum2(&incoming_packet, value); } void *