summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-04-03 14:18:58 +0200
committerChristian Grothoff <christian@grothoff.org>2020-04-03 14:18:58 +0200
commit175303b445903df39e0ba769820a6768352ccac4 (patch)
tree8f4dc6a1047646cb4cf4b6443918bafc7054a814 /src/util
parent225ddf0a2f704547e49ac3c3878b9015c915a02a (diff)
fix #6154
Diffstat (limited to 'src/util')
-rw-r--r--src/util/strings.c22
1 files 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--;
}