From 27f7c2cbede339827597bfcadb469af6745c2e07 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 15 Nov 2012 09:38:33 +0000 Subject: - bug hunting --- src/transport/plugin_transport_udp.c | 24 +++++++++++++++++++----- src/transport/plugin_transport_udp.h | 6 ++++++ 2 files changed, 25 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index dd5d6388f..4333432cc 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -979,6 +979,16 @@ free_session (struct Session *s) static void dequeue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) { + if (plugin->bytes_in_buffer - udpw->msg_size < 0) + GNUNET_break (0); + else + { + GNUNET_STATISTICS_update (plugin->env->stats, + "# UDP, total, bytes in buffers", + udpw->msg_size, GNUNET_NO); + plugin->bytes_in_buffer -= udpw->msg_size; + } + GNUNET_STATISTICS_update (plugin->env->stats, "# UDP, total, bytes in buffers", -udpw->msg_size, GNUNET_NO); @@ -1015,7 +1025,6 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, int result) call_continuation (&dummy, result); - /* Remove left-over fragments from queue */ /* Remove leftover fragments from queue */ if (s->addrlen == sizeof (struct sockaddr_in6)) { @@ -1440,13 +1449,18 @@ udp_plugin_get_session (void *cls, return s; } - static void enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) { - GNUNET_STATISTICS_update (plugin->env->stats, - "# UDP, total, bytes in buffers", - udpw->msg_size, GNUNET_NO); + if (plugin->bytes_in_buffer + udpw->msg_size > INT64_MAX) + GNUNET_break (0); + else + { + GNUNET_STATISTICS_update (plugin->env->stats, + "# UDP, total, bytes in buffers", + udpw->msg_size, GNUNET_NO); + plugin->bytes_in_buffer += udpw->msg_size; + } GNUNET_STATISTICS_update (plugin->env->stats, "# UDP, total, msgs in buffers", 1, GNUNET_NO); diff --git a/src/transport/plugin_transport_udp.h b/src/transport/plugin_transport_udp.h index 3bdf4a561..bab8e6cf0 100644 --- a/src/transport/plugin_transport_udp.h +++ b/src/transport/plugin_transport_udp.h @@ -159,6 +159,12 @@ struct Plugin */ char *bind6_address; + + /** + * Bytes currently in buffer + */ + int64_t bytes_in_buffer; + /** * Handle to NAT traversal support. */ -- cgit v1.2.3