aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/cadet_api.c
diff options
context:
space:
mode:
authorDavid Barksdale <amatus@amat.us>2017-12-27 11:24:37 -0600
committerDavid Barksdale <amatus@amat.us>2017-12-27 11:24:37 -0600
commit9c13c44768d048339c5b1c48d4b0ef35000c524d (patch)
treeac06050dec45c7617fc3986362f79705dd29648c /src/cadet/cadet_api.c
parent9995f2609595f7be49a266e094877c746a4fc73d (diff)
downloadgnunet-9c13c44768d048339c5b1c48d4b0ef35000c524d.tar.gz
gnunet-9c13c44768d048339c5b1c48d4b0ef35000c524d.zip
Fix handling of GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS
This fixes issue #5079
Diffstat (limited to 'src/cadet/cadet_api.c')
-rw-r--r--src/cadet/cadet_api.c56
1 files changed, 44 insertions, 12 deletions
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c
index ea6ef719b..37de27db1 100644
--- a/src/cadet/cadet_api.c
+++ b/src/cadet/cadet_api.c
@@ -978,6 +978,29 @@ handle_get_peer (void *cls,
978 978
979 979
980/** 980/**
981 * Check that message received from CADET service is well-formed.
982 *
983 * @param cls the `struct GNUNET_CADET_Handle`
984 * @param message the message we got
985 * @return #GNUNET_OK if the message is well-formed,
986 * #GNUNET_SYSERR otherwise
987 */
988static int
989check_get_tunnels (void *cls,
990 const struct GNUNET_MessageHeader *message)
991{
992 size_t esize;
993
994 esize = ntohs (message->size);
995 if (sizeof (struct GNUNET_CADET_LocalInfoTunnel) == esize)
996 return GNUNET_OK;
997 if (sizeof (struct GNUNET_MessageHeader) == esize)
998 return GNUNET_OK;
999 return GNUNET_SYSERR;
1000}
1001
1002
1003/**
981 * Process a local reply about info on all tunnels, pass info to the user. 1004 * Process a local reply about info on all tunnels, pass info to the user.
982 * 1005 *
983 * @param cls Closure (Cadet handle). 1006 * @param cls Closure (Cadet handle).
@@ -985,19 +1008,28 @@ handle_get_peer (void *cls,
985 */ 1008 */
986static void 1009static void
987handle_get_tunnels (void *cls, 1010handle_get_tunnels (void *cls,
988 const struct GNUNET_CADET_LocalInfoTunnel *msg) 1011 const struct GNUNET_MessageHeader *msg)
989{ 1012{
990 struct GNUNET_CADET_Handle *h = cls; 1013 struct GNUNET_CADET_Handle *h = cls;
1014 const struct GNUNET_CADET_LocalInfoTunnel *info =
1015 (const struct GNUNET_CADET_LocalInfoTunnel *) msg;
991 1016
992 if (NULL == h->info_cb.tunnels_cb) 1017 if (NULL == h->info_cb.tunnels_cb)
993 return; 1018 return;
994 h->info_cb.tunnels_cb (h->info_cls, 1019 if (sizeof (struct GNUNET_CADET_LocalInfoTunnel) == ntohs (msg->size))
995 &msg->destination, 1020 h->info_cb.tunnels_cb (h->info_cls,
996 ntohl (msg->channels), 1021 &info->destination,
997 ntohl (msg->connections), 1022 ntohl (info->channels),
998 ntohs (msg->estate), 1023 ntohl (info->connections),
999 ntohs (msg->cstate)); 1024 ntohs (info->estate),
1000 1025 ntohs (info->cstate));
1026 else
1027 h->info_cb.tunnels_cb (h->info_cls,
1028 NULL,
1029 0,
1030 0,
1031 0,
1032 0);
1001} 1033}
1002 1034
1003 1035
@@ -1115,10 +1147,10 @@ reconnect (struct GNUNET_CADET_Handle *h)
1115 GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER, 1147 GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER,
1116 struct GNUNET_CADET_LocalInfoPeer, 1148 struct GNUNET_CADET_LocalInfoPeer,
1117 h), 1149 h),
1118 GNUNET_MQ_hd_fixed_size (get_tunnels, 1150 GNUNET_MQ_hd_var_size (get_tunnels,
1119 GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS, 1151 GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS,
1120 struct GNUNET_CADET_LocalInfoTunnel, 1152 struct GNUNET_MessageHeader,
1121 h), 1153 h),
1122 GNUNET_MQ_hd_var_size (get_tunnel, 1154 GNUNET_MQ_hd_var_size (get_tunnel,
1123 GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL, 1155 GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL,
1124 struct GNUNET_CADET_LocalInfoTunnel, 1156 struct GNUNET_CADET_LocalInfoTunnel,