From 6532ac1037b448508642d4d97d21ab103bd6735c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 6 Jan 2018 21:22:23 +0100 Subject: [PATCH] internally assert that asprintf size allocation never fails --- src/transport/plugin_transport_tcp.c | 7 ++++--- src/util/common_allocation.c | 1 + src/util/configuration.c | 1 - 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index c5d6e6d34..8b00543c3 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -3351,9 +3351,10 @@ handle_tcp_data (void *cls, void *vaddr = NULL; size_t alen; - GNUNET_SERVER_client_get_address (client, - &vaddr, - &alen); + GNUNET_assert (GNUNET_OK == + GNUNET_SERVER_client_get_address (client, + &vaddr, + &alen)); LOG (GNUNET_ERROR_TYPE_ERROR, "Received unexpected %u bytes of type %u from `%s'\n", (unsigned int) ntohs (message->size), diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index be2538c3f..80047bb52 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c @@ -484,6 +484,7 @@ GNUNET_asprintf (char **buf, va_start (args, format); ret = VSNPRINTF (NULL, 0, format, args); va_end (args); + GNUNET_assert (ret >= 0); *buf = GNUNET_malloc (ret + 1); va_start (args, format); ret = VSPRINTF (*buf, format, args); diff --git a/src/util/configuration.c b/src/util/configuration.c index 7f1d98902..25eeaf80f 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c @@ -421,7 +421,6 @@ GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg, size_t m_size; size_t c_size; - /* Pass1 : calculate the buffer size required */ m_size = 0; for (sec = cfg->sections; NULL != sec; sec = sec->next) -- 2.25.1