From: Vladimír Čunát Date: Mon, 3 May 2021 17:53:35 +0000 (+0200) Subject: dnstap: avoid a false-positive warning X-Git-Tag: v5.4.1~4^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=666947db27e6d85b577576ec887c721df64a5980;p=thirdparty%2Fknot-resolver.git dnstap: avoid a false-positive warning ../modules/dnstap/dnstap.c: In function 'dnstap_config': ../modules/dnstap/dnstap.c:410:29: warning: 'strndup' specified bound 4096 exceeds source size 17 [-Wstringop-overread] 410 | sock_path = strndup(DEFAULT_SOCK_PATH, PATH_MAX); | ^ ../modules/dnstap/dnstap.c:423:37: warning: 'strndup' specified bound 4096 exceeds source size 17 [-Wstringop-overread] 423 | sock_path = strndup(DEFAULT_SOCK_PATH, PATH_MAX); | ^ We don't need to restrict our built-in path defaults to PATH_MAX characters, as they just can't be that long and it's not an issue if we shoot over it anyway - opening such a file would only fail. --- diff --git a/modules/dnstap/dnstap.c b/modules/dnstap/dnstap.c index 1182a3ce2..f8b471fcc 100644 --- a/modules/dnstap/dnstap.c +++ b/modules/dnstap/dnstap.c @@ -409,7 +409,7 @@ int dnstap_config(struct kr_module *module, const char *conf) { /* Empty conf passed, set default */ if (!conf || strlen(conf) < 1) { - sock_path = strndup(DEFAULT_SOCK_PATH, PATH_MAX); + sock_path = strdup(DEFAULT_SOCK_PATH); } else { JsonNode *root_node = json_decode(conf); @@ -422,7 +422,7 @@ int dnstap_config(struct kr_module *module, const char *conf) { /* dnstapPath key */ node = json_find_member(root_node, CFG_SOCK_PATH); if (!node || find_string(node, &sock_path, PATH_MAX) != kr_ok()) { - sock_path = strndup(DEFAULT_SOCK_PATH, PATH_MAX); + sock_path = strdup(DEFAULT_SOCK_PATH); } /* identity string key */