diff options
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 36 |
1 files changed, 14 insertions, 22 deletions
@@ -37,7 +37,7 @@ | |||
37 | */ | 37 | */ |
38 | 38 | ||
39 | #include "includes.h" | 39 | #include "includes.h" |
40 | RCSID("$OpenBSD: packet.c,v 1.81 2001/12/28 14:13:13 markus Exp $"); | 40 | RCSID("$OpenBSD: packet.c,v 1.82 2001/12/28 14:50:54 markus Exp $"); |
41 | 41 | ||
42 | #include "xmalloc.h" | 42 | #include "xmalloc.h" |
43 | #include "buffer.h" | 43 | #include "buffer.h" |
@@ -610,7 +610,7 @@ packet_send(void) | |||
610 | */ | 610 | */ |
611 | 611 | ||
612 | int | 612 | int |
613 | packet_read_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) | 613 | packet_read_seqnr(u_int32_t *seqnr_p) |
614 | { | 614 | { |
615 | int type, len; | 615 | int type, len; |
616 | fd_set *setp; | 616 | fd_set *setp; |
@@ -626,7 +626,7 @@ packet_read_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) | |||
626 | /* Stay in the loop until we have received a complete packet. */ | 626 | /* Stay in the loop until we have received a complete packet. */ |
627 | for (;;) { | 627 | for (;;) { |
628 | /* Try to read a packet from the buffer. */ | 628 | /* Try to read a packet from the buffer. */ |
629 | type = packet_read_poll_seqnr(payload_len_ptr, seqnr_p); | 629 | type = packet_read_poll_seqnr(seqnr_p); |
630 | if (!compat20 && ( | 630 | if (!compat20 && ( |
631 | type == SSH_SMSG_SUCCESS | 631 | type == SSH_SMSG_SUCCESS |
632 | || type == SSH_SMSG_FAILURE | 632 | || type == SSH_SMSG_FAILURE |
@@ -666,9 +666,9 @@ packet_read_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) | |||
666 | } | 666 | } |
667 | 667 | ||
668 | int | 668 | int |
669 | packet_read(int *payload_len_ptr) | 669 | packet_read(void) |
670 | { | 670 | { |
671 | return packet_read_seqnr(payload_len_ptr, NULL); | 671 | return packet_read_seqnr(NULL); |
672 | } | 672 | } |
673 | 673 | ||
674 | /* | 674 | /* |
@@ -677,11 +677,11 @@ packet_read(int *payload_len_ptr) | |||
677 | */ | 677 | */ |
678 | 678 | ||
679 | void | 679 | void |
680 | packet_read_expect(int *payload_len_ptr, int expected_type) | 680 | packet_read_expect(int expected_type) |
681 | { | 681 | { |
682 | int type; | 682 | int type; |
683 | 683 | ||
684 | type = packet_read(payload_len_ptr); | 684 | type = packet_read(); |
685 | if (type != expected_type) | 685 | if (type != expected_type) |
686 | packet_disconnect("Protocol error: expected packet type %d, got %d", | 686 | packet_disconnect("Protocol error: expected packet type %d, got %d", |
687 | expected_type, type); | 687 | expected_type, type); |
@@ -694,16 +694,10 @@ packet_read_expect(int *payload_len_ptr, int expected_type) | |||
694 | * SSH_MSG_DISCONNECT is handled specially here. Also, | 694 | * SSH_MSG_DISCONNECT is handled specially here. Also, |
695 | * SSH_MSG_IGNORE messages are skipped by this function and are never returned | 695 | * SSH_MSG_IGNORE messages are skipped by this function and are never returned |
696 | * to higher levels. | 696 | * to higher levels. |
697 | * | ||
698 | * The returned payload_len does include space consumed by: | ||
699 | * Packet length | ||
700 | * Padding | ||
701 | * Packet type | ||
702 | * Check bytes | ||
703 | */ | 697 | */ |
704 | 698 | ||
705 | static int | 699 | static int |
706 | packet_read_poll1(int *payload_len_ptr) | 700 | packet_read_poll1(void) |
707 | { | 701 | { |
708 | u_int len, padded_len; | 702 | u_int len, padded_len; |
709 | u_char *ucp, type; | 703 | u_char *ucp, type; |
@@ -776,12 +770,11 @@ packet_read_poll1(int *payload_len_ptr) | |||
776 | buffer_len(&compression_buffer)); | 770 | buffer_len(&compression_buffer)); |
777 | } | 771 | } |
778 | type = buffer_get_char(&incoming_packet); | 772 | type = buffer_get_char(&incoming_packet); |
779 | *payload_len_ptr = buffer_len(&incoming_packet); | ||
780 | return type; | 773 | return type; |
781 | } | 774 | } |
782 | 775 | ||
783 | static int | 776 | static int |
784 | packet_read_poll2(int *payload_len_ptr, u_int32_t *seqnr_p) | 777 | packet_read_poll2(u_int32_t *seqnr_p) |
785 | { | 778 | { |
786 | static u_int32_t seqnr = 0; | 779 | static u_int32_t seqnr = 0; |
787 | static u_int packet_length = 0; | 780 | static u_int packet_length = 0; |
@@ -887,7 +880,6 @@ packet_read_poll2(int *payload_len_ptr, u_int32_t *seqnr_p) | |||
887 | type = buffer_get_char(&incoming_packet); | 880 | type = buffer_get_char(&incoming_packet); |
888 | if (type == SSH2_MSG_NEWKEYS) | 881 | if (type == SSH2_MSG_NEWKEYS) |
889 | set_newkeys(MODE_IN); | 882 | set_newkeys(MODE_IN); |
890 | *payload_len_ptr = buffer_len(&incoming_packet); | ||
891 | #ifdef PACKET_DEBUG | 883 | #ifdef PACKET_DEBUG |
892 | fprintf(stderr, "read/plain[%d]:\r\n", type); | 884 | fprintf(stderr, "read/plain[%d]:\r\n", type); |
893 | buffer_dump(&incoming_packet); | 885 | buffer_dump(&incoming_packet); |
@@ -898,7 +890,7 @@ packet_read_poll2(int *payload_len_ptr, u_int32_t *seqnr_p) | |||
898 | } | 890 | } |
899 | 891 | ||
900 | int | 892 | int |
901 | packet_read_poll_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) | 893 | packet_read_poll_seqnr(u_int32_t *seqnr_p) |
902 | { | 894 | { |
903 | int reason; | 895 | int reason; |
904 | u_char type; | 896 | u_char type; |
@@ -906,7 +898,7 @@ packet_read_poll_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) | |||
906 | 898 | ||
907 | for (;;) { | 899 | for (;;) { |
908 | if (compat20) { | 900 | if (compat20) { |
909 | type = packet_read_poll2(payload_len_ptr, seqnr_p); | 901 | type = packet_read_poll2(seqnr_p); |
910 | if (type) | 902 | if (type) |
911 | DBG(debug("received packet type %d", type)); | 903 | DBG(debug("received packet type %d", type)); |
912 | switch (type) { | 904 | switch (type) { |
@@ -933,7 +925,7 @@ packet_read_poll_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) | |||
933 | break; | 925 | break; |
934 | } | 926 | } |
935 | } else { | 927 | } else { |
936 | type = packet_read_poll1(payload_len_ptr); | 928 | type = packet_read_poll1(); |
937 | switch (type) { | 929 | switch (type) { |
938 | case SSH_MSG_IGNORE: | 930 | case SSH_MSG_IGNORE: |
939 | break; | 931 | break; |
@@ -960,9 +952,9 @@ packet_read_poll_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) | |||
960 | } | 952 | } |
961 | 953 | ||
962 | int | 954 | int |
963 | packet_read_poll(int *payload_len_ptr) | 955 | packet_read_poll(void) |
964 | { | 956 | { |
965 | return packet_read_poll_seqnr(payload_len_ptr, NULL); | 957 | return packet_read_poll_seqnr(NULL); |
966 | } | 958 | } |
967 | 959 | ||
968 | /* | 960 | /* |