diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-12-19 22:01:50 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-12-19 22:01:50 +0000 |
commit | 5a03634851a77f29e4dffb8d80b094be226687b0 (patch) | |
tree | ded1de79df67b98b90c7f74097cb522f34ad9761 /src/multicast/multicast_api.c | |
parent | bbdd32ba7bb61fe29790ad9d0d05918c5ef08208 (diff) |
-fix leak
Diffstat (limited to 'src/multicast/multicast_api.c')
-rw-r--r-- | src/multicast/multicast_api.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/multicast/multicast_api.c b/src/multicast/multicast_api.c index aa15edccfb..cda451eb8b 100644 --- a/src/multicast/multicast_api.c +++ b/src/multicast/multicast_api.c @@ -223,23 +223,30 @@ group_recv_join_request (void *cls, struct GNUNET_CLIENT_MANAGER_Connection *client, const struct GNUNET_MessageHeader *msg) { - struct GNUNET_MULTICAST_Group * - grp = GNUNET_CLIENT_MANAGER_get_user_context_ (client, sizeof (*grp)); - - const struct MulticastJoinRequestMessage * - jreq = (const struct MulticastJoinRequestMessage *) msg; + struct GNUNET_MULTICAST_Group *grp; + const struct MulticastJoinRequestMessage *jreq; + struct GNUNET_MULTICAST_JoinHandle *jh; + const struct GNUNET_MessageHeader *jmsg; - struct GNUNET_MULTICAST_JoinHandle *jh = GNUNET_malloc (sizeof (*jh)); + grp = GNUNET_CLIENT_MANAGER_get_user_context_ (client, sizeof (*grp)); + if (NULL == grp) + { + GNUNET_break (0); + return; + } + if (NULL == grp->join_req_cb) + return; + /* FIXME: this fails to check that 'msg' is well-formed! */ + jreq = (const struct MulticastJoinRequestMessage *) msg; + if (sizeof (*jreq) + sizeof (*jmsg) <= ntohs (jreq->header.size)) + jmsg = (const struct GNUNET_MessageHeader *) &jreq[1]; + else + jmsg = NULL; + jh = GNUNET_malloc (sizeof (*jh)); jh->group = grp; jh->member_key = jreq->member_key; jh->peer = jreq->peer; - - const struct GNUNET_MessageHeader *jmsg = NULL; - if (sizeof (*jreq) + sizeof (*jmsg) <= ntohs (jreq->header.size)) - jmsg = (const struct GNUNET_MessageHeader *) &jreq[1]; - - if (NULL != grp->join_req_cb) - grp->join_req_cb (grp->cb_cls, &jreq->member_key, jmsg, jh); + grp->join_req_cb (grp->cb_cls, &jreq->member_key, jmsg, jh); } |