diff options
author | Damien Miller <djm@mindrot.org> | 2001-12-21 15:00:19 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2001-12-21 15:00:19 +1100 |
commit | 278f907a2d6d00d6f52a11bf9577648aadbf0994 (patch) | |
tree | 50f885a7fd73b813754e3b675e810dc01ba78b78 /packet.c | |
parent | e737856350287104a12f5a97c81fad1f7bcd7096 (diff) |
- djm@cvs.openbsd.org 2001/12/20 22:50:24
[auth2.c auth2-chall.c channels.c channels.h clientloop.c dispatch.c]
[dispatch.h kex.c kex.h packet.c packet.h serverloop.c ssh.c]
[sshconnect2.c]
Conformance fix: we should send failing packet sequence number when
responding with a SSH_MSG_UNIMPLEMENTED message. Spotted by
yakk@yakk.dot.net; ok markus@
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 28 |
1 files changed, 21 insertions, 7 deletions
@@ -37,7 +37,7 @@ | |||
37 | */ | 37 | */ |
38 | 38 | ||
39 | #include "includes.h" | 39 | #include "includes.h" |
40 | RCSID("$OpenBSD: packet.c,v 1.76 2001/12/19 17:16:13 stevesk Exp $"); | 40 | RCSID("$OpenBSD: packet.c,v 1.77 2001/12/20 22:50:24 djm 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(int *payload_len_ptr) | 613 | packet_read_seqnr(int *payload_len_ptr, 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(int *payload_len_ptr) | |||
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(payload_len_ptr); | 629 | type = packet_read_poll_seqnr(payload_len_ptr, 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 |
@@ -665,6 +665,12 @@ packet_read(int *payload_len_ptr) | |||
665 | /* NOTREACHED */ | 665 | /* NOTREACHED */ |
666 | } | 666 | } |
667 | 667 | ||
668 | int | ||
669 | packet_read(int *payload_len_ptr) | ||
670 | { | ||
671 | return packet_read_seqnr(payload_len_ptr, NULL); | ||
672 | } | ||
673 | |||
668 | /* | 674 | /* |
669 | * Waits until a packet has been received, verifies that its type matches | 675 | * Waits until a packet has been received, verifies that its type matches |
670 | * that given, and gives a fatal error and exits if there is a mismatch. | 676 | * that given, and gives a fatal error and exits if there is a mismatch. |
@@ -753,7 +759,7 @@ packet_read_poll1(int *payload_len_ptr) | |||
753 | 759 | ||
754 | /* Test check bytes. */ | 760 | /* Test check bytes. */ |
755 | if (len != buffer_len(&incoming_packet)) | 761 | if (len != buffer_len(&incoming_packet)) |
756 | packet_disconnect("packet_read_poll: len %d != buffer_len %d.", | 762 | packet_disconnect("packet_read_poll1: len %d != buffer_len %d.", |
757 | len, buffer_len(&incoming_packet)); | 763 | len, buffer_len(&incoming_packet)); |
758 | 764 | ||
759 | ucp = (u_char *) buffer_ptr(&incoming_packet) + len - 4; | 765 | ucp = (u_char *) buffer_ptr(&incoming_packet) + len - 4; |
@@ -775,7 +781,7 @@ packet_read_poll1(int *payload_len_ptr) | |||
775 | } | 781 | } |
776 | 782 | ||
777 | static int | 783 | static int |
778 | packet_read_poll2(int *payload_len_ptr) | 784 | packet_read_poll2(int *payload_len_ptr, u_int32_t *seqnr_p) |
779 | { | 785 | { |
780 | static u_int32_t seqnr = 0; | 786 | static u_int32_t seqnr = 0; |
781 | static u_int packet_length = 0; | 787 | static u_int packet_length = 0; |
@@ -848,6 +854,8 @@ packet_read_poll2(int *payload_len_ptr) | |||
848 | DBG(debug("MAC #%d ok", seqnr)); | 854 | DBG(debug("MAC #%d ok", seqnr)); |
849 | buffer_consume(&input, mac->mac_len); | 855 | buffer_consume(&input, mac->mac_len); |
850 | } | 856 | } |
857 | if (seqnr_p != NULL) | ||
858 | *seqnr_p = seqnr; | ||
851 | if (++seqnr == 0) | 859 | if (++seqnr == 0) |
852 | log("incoming seqnr wraps around"); | 860 | log("incoming seqnr wraps around"); |
853 | 861 | ||
@@ -890,7 +898,7 @@ packet_read_poll2(int *payload_len_ptr) | |||
890 | } | 898 | } |
891 | 899 | ||
892 | int | 900 | int |
893 | packet_read_poll(int *payload_len_ptr) | 901 | packet_read_poll_seqnr(int *payload_len_ptr, u_int32_t *seqnr_p) |
894 | { | 902 | { |
895 | int reason; | 903 | int reason; |
896 | u_char type; | 904 | u_char type; |
@@ -898,7 +906,7 @@ packet_read_poll(int *payload_len_ptr) | |||
898 | 906 | ||
899 | for (;;) { | 907 | for (;;) { |
900 | if (compat20) { | 908 | if (compat20) { |
901 | type = packet_read_poll2(payload_len_ptr); | 909 | type = packet_read_poll2(payload_len_ptr, seqnr_p); |
902 | if (type) | 910 | if (type) |
903 | DBG(debug("received packet type %d", type)); | 911 | DBG(debug("received packet type %d", type)); |
904 | switch (type) { | 912 | switch (type) { |
@@ -951,6 +959,12 @@ packet_read_poll(int *payload_len_ptr) | |||
951 | } | 959 | } |
952 | } | 960 | } |
953 | 961 | ||
962 | int | ||
963 | packet_read_poll(int *payload_len_ptr) | ||
964 | { | ||
965 | return packet_read_poll_seqnr(payload_len_ptr, NULL); | ||
966 | } | ||
967 | |||
954 | /* | 968 | /* |
955 | * Buffers the given amount of input characters. This is intended to be used | 969 | * Buffers the given amount of input characters. This is intended to be used |
956 | * together with packet_read_poll. | 970 | * together with packet_read_poll. |