From 175303b445903df39e0ba769820a6768352ccac4 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 3 Apr 2020 14:18:58 +0200 Subject: [PATCH] fix #6154 --- src/util/strings.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) 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--; } -- 2.25.1