From 6d7fd3328a2ffe42ef52f914d913f1ee4d290adc Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 3 Apr 2020 18:50:09 +0200 Subject: [PATCH] fix #6157 --- src/util/strings.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/util/strings.c b/src/util/strings.c index be2ec33dc..9510b3b3b 100644 --- a/src/util/strings.c +++ b/src/util/strings.c @@ -972,14 +972,14 @@ GNUNET_STRINGS_string_to_data (const char *enc, void *out, size_t out_size) { - unsigned int rpos; - unsigned int wpos; + size_t rpos; + size_t wpos; unsigned int bits; unsigned int vbit; int ret; int shift; unsigned char *uout; - unsigned int encoded_len = out_size * 8; + size_t encoded_len; if (0 == enclen) { @@ -987,6 +987,8 @@ GNUNET_STRINGS_string_to_data (const char *enc, return GNUNET_OK; return GNUNET_SYSERR; } + GNUNET_assert (out_size < SIZE_MAX / 8); + encoded_len = out_size * 8; uout = out; wpos = out_size; rpos = enclen; -- 2.25.1