From: Christian Grothoff Date: Tue, 3 Mar 2020 11:31:23 +0000 (+0100) Subject: make static analysis happier X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d1bdcb2618b13c3289492347550feb3fcf1f812d;p=oweals%2Fgnunet.git make static analysis happier --- diff --git a/src/util/configuration.c b/src/util/configuration.c index 0480ebd5d..7ed87cc1e 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c @@ -1241,7 +1241,7 @@ GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, * @param cfg configuration to use for path expansion * @param orig string to $-expand (will be freed!) * @param depth recursion depth, used to detect recursive expansions - * @return $-expanded string + * @return $-expanded string, never NULL unless @a orig was NULL */ static char * expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, @@ -1421,6 +1421,7 @@ GNUNET_CONFIGURATION_expand_dollar ( continue; dup = GNUNET_strdup (orig + i); dup = expand_dollar (cfg, dup, 0); + GNUNET_assert (NULL != dup); /* make compiler happy */ len = strlen (dup) + 1; orig = GNUNET_realloc (orig, i + len); GNUNET_memcpy (orig + i, dup, len); diff --git a/src/util/strings.c b/src/util/strings.c index a291dc4e1..f3089bf65 100644 --- a/src/util/strings.c +++ b/src/util/strings.c @@ -1932,6 +1932,7 @@ GNUNET_STRINGS_base64url_encode (const void *in, size_t len, char **output) return strlen (enc); } + #define cvtfind(a) \ ((((a) >= 'A') && ((a) <= 'Z')) \ ? (a) - 'A' \ @@ -1964,7 +1965,7 @@ GNUNET_STRINGS_base64_decode (const char *data, size_t len, void **out) "ignoring CR/LF\n"); \ i++; \ if (i >= len) \ - goto END; \ + goto END; \ } output = GNUNET_malloc ((len * 3 / 4) + 8); @@ -2046,16 +2047,20 @@ GNUNET_STRINGS_base64url_decode (const char *data, size_t len, void **out) case 0: break; // No pad chars in this case case 2: - strncpy (&s[len], "==", 2); + memcpy (&s[len], + "==", + 2); + len += 2; break; // Two pad chars case 3: s[len] = '='; + len++; break; // One pad char default: GNUNET_assert (0); break; } - ret = GNUNET_STRINGS_base64_decode (s, strlen (s), out); + ret = GNUNET_STRINGS_base64_decode (s, len, out); GNUNET_free (s); return ret; }