From: Philipp Tölke Date: Wed, 5 Oct 2011 09:41:31 +0000 (+0000) Subject: core gives a buf of NULL to indicate errors X-Git-Tag: initial-import-from-subversion-38251~16797 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=cc632e434054d618798957fcdb1804f69c8dfc78;p=oweals%2Fgnunet.git core gives a buf of NULL to indicate errors --- diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 4b6731d3f..5bb7d1403 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c @@ -675,6 +675,9 @@ core_notify (void *cls, size_t size, void *buf) struct notify_cls *ncls = cls; struct GNUNET_MESH_Tunnel *tunnel = ncls->tunnel; + if (NULL == buf) + return ncls->notify (ncls->notify_cls, 0, NULL); + tunnel->notify_handle = NULL; struct tunnel_message *message = buf; void *cbuf = (void *) &message[1]; diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c index 9c944ebef..fbbffc9a1 100644 --- a/src/vpn/gnunet-daemon-vpn.c +++ b/src/vpn/gnunet-daemon-vpn.c @@ -283,15 +283,21 @@ send_pkt_to_peer_notify_callback (void *cls, size_t size, void *buf) struct GNUNET_MESH_Tunnel **tunnel = cls; GNUNET_MESH_tunnel_set_data (*tunnel, NULL); - struct GNUNET_MessageHeader *hdr = - (struct GNUNET_MessageHeader *) (tunnel + 1); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "send_pkt_to_peer_notify_callback: buf = %x; size = %u;\n", buf, - size); - GNUNET_assert (size >= ntohs (hdr->size)); - memcpy (buf, hdr, ntohs (hdr->size)); - size = ntohs (hdr->size); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent!\n"); + + if (NULL != buf) + { + struct GNUNET_MessageHeader *hdr = + (struct GNUNET_MessageHeader *) (tunnel + 1); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "send_pkt_to_peer_notify_callback: buf = %x; size = %u;\n", buf, + size); + GNUNET_assert (size >= ntohs (hdr->size)); + memcpy (buf, hdr, ntohs (hdr->size)); + size = ntohs (hdr->size); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent!\n"); + } + else + size = 0; if (NULL != GNUNET_MESH_tunnel_get_head (*tunnel)) {