From: Christian Grothoff Date: Fri, 3 Apr 2020 12:18:58 +0000 (+0200) Subject: fix #6154 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=175303b445903df39e0ba769820a6768352ccac4;p=oweals%2Fgnunet.git fix #6154 --- diff --git a/src/util/strings.c b/src/util/strings.c index f32c3ea61..54a594c51 100644 --- a/src/util/strings.c +++ b/src/util/strings.c @@ -62,25 +62,25 @@ * (or number of bytes that would have been written) */ size_t -GNUNET_STRINGS_buffer_fill (char *buffer, size_t size, unsigned int count, ...) +GNUNET_STRINGS_buffer_fill (char *buffer, + size_t size, + unsigned int count, ...) { size_t needed; - size_t slen; - const char *s; va_list ap; needed = 0; va_start (ap, count); while (count > 0) { - s = va_arg (ap, const char *); - - slen = strlen (s) + 1; - if (buffer != NULL) - { - GNUNET_assert (needed + slen <= size); - GNUNET_memcpy (&buffer[needed], s, slen); - } + const char *s = va_arg (ap, const char *); + size_t slen = strlen (s) + 1; + + GNUNET_assert (slen <= size - needed); + if (NULL != buffer) + GNUNET_memcpy (&buffer[needed], + s, + slen); needed += slen; count--; }