diff options
author | David Barksdale <amatus@amat.us> | 2017-12-27 10:55:10 -0600 |
---|---|---|
committer | David Barksdale <amatus@amat.us> | 2017-12-27 10:57:33 -0600 |
commit | 9995f2609595f7be49a266e094877c746a4fc73d (patch) | |
tree | aa566eb30d0497acaa134ff7ce42738b4016924c /src/cadet/cadet_api.c | |
parent | 228e08b13cd1419f3f19f96bf1a2b50f14172c36 (diff) | |
download | gnunet-9995f2609595f7be49a266e094877c746a4fc73d.tar.gz gnunet-9995f2609595f7be49a266e094877c746a4fc73d.zip |
Fix handling of GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS
This fixes issue #4621
Diffstat (limited to 'src/cadet/cadet_api.c')
-rw-r--r-- | src/cadet/cadet_api.c | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c index 4d923080a..ea6ef719b 100644 --- a/src/cadet/cadet_api.c +++ b/src/cadet/cadet_api.c | |||
@@ -824,6 +824,29 @@ handle_mq_error (void *cls, | |||
824 | 824 | ||
825 | 825 | ||
826 | /** | 826 | /** |
827 | * Check that message received from CADET service is well-formed. | ||
828 | * | ||
829 | * @param cls the `struct GNUNET_CADET_Handle` | ||
830 | * @param message the message we got | ||
831 | * @return #GNUNET_OK if the message is well-formed, | ||
832 | * #GNUNET_SYSERR otherwise | ||
833 | */ | ||
834 | static int | ||
835 | check_get_peers (void *cls, | ||
836 | const struct GNUNET_MessageHeader *message) | ||
837 | { | ||
838 | size_t esize; | ||
839 | |||
840 | esize = ntohs (message->size); | ||
841 | if (sizeof (struct GNUNET_CADET_LocalInfoPeer) == esize) | ||
842 | return GNUNET_OK; | ||
843 | if (sizeof (struct GNUNET_MessageHeader) == esize) | ||
844 | return GNUNET_OK; | ||
845 | return GNUNET_SYSERR; | ||
846 | } | ||
847 | |||
848 | |||
849 | /** | ||
827 | * Process a local reply about info on all tunnels, pass info to the user. | 850 | * Process a local reply about info on all tunnels, pass info to the user. |
828 | * | 851 | * |
829 | * @param cls Closure (Cadet handle). | 852 | * @param cls Closure (Cadet handle). |
@@ -831,17 +854,26 @@ handle_mq_error (void *cls, | |||
831 | */ | 854 | */ |
832 | static void | 855 | static void |
833 | handle_get_peers (void *cls, | 856 | handle_get_peers (void *cls, |
834 | const struct GNUNET_CADET_LocalInfoPeer *msg) | 857 | const struct GNUNET_MessageHeader *msg) |
835 | { | 858 | { |
836 | struct GNUNET_CADET_Handle *h = cls; | 859 | struct GNUNET_CADET_Handle *h = cls; |
860 | const struct GNUNET_CADET_LocalInfoPeer *info = | ||
861 | (const struct GNUNET_CADET_LocalInfoPeer *) msg; | ||
837 | 862 | ||
838 | if (NULL == h->info_cb.peers_cb) | 863 | if (NULL == h->info_cb.peers_cb) |
839 | return; | 864 | return; |
840 | h->info_cb.peers_cb (h->info_cls, | 865 | if (sizeof (struct GNUNET_CADET_LocalInfoPeer) == ntohs (msg->size)) |
841 | &msg->destination, | 866 | h->info_cb.peers_cb (h->info_cls, |
842 | (int) ntohs (msg->tunnel), | 867 | &info->destination, |
843 | (unsigned int) ntohs (msg->paths), | 868 | (int) ntohs (info->tunnel), |
844 | 0); | 869 | (unsigned int) ntohs (info->paths), |
870 | 0); | ||
871 | else | ||
872 | h->info_cb.peers_cb (h->info_cls, | ||
873 | NULL, | ||
874 | 0, | ||
875 | 0, | ||
876 | 0); | ||
845 | } | 877 | } |
846 | 878 | ||
847 | 879 | ||
@@ -1075,10 +1107,10 @@ reconnect (struct GNUNET_CADET_Handle *h) | |||
1075 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK, | 1107 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK, |
1076 | struct GNUNET_CADET_LocalAck, | 1108 | struct GNUNET_CADET_LocalAck, |
1077 | h), | 1109 | h), |
1078 | GNUNET_MQ_hd_fixed_size (get_peers, | 1110 | GNUNET_MQ_hd_var_size (get_peers, |
1079 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS, | 1111 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS, |
1080 | struct GNUNET_CADET_LocalInfoPeer, | 1112 | struct GNUNET_MessageHeader, |
1081 | h), | 1113 | h), |
1082 | GNUNET_MQ_hd_var_size (get_peer, | 1114 | GNUNET_MQ_hd_var_size (get_peer, |
1083 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER, | 1115 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER, |
1084 | struct GNUNET_CADET_LocalInfoPeer, | 1116 | struct GNUNET_CADET_LocalInfoPeer, |