]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
dnstap: avoid a false-positive warning
authorVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 3 May 2021 17:53:35 +0000 (19:53 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 9 Aug 2021 06:28:40 +0000 (08:28 +0200)
../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.

modules/dnstap/dnstap.c

index 1182a3ce2358e7bef48463e9fe8f972509bf0c7d..f8b471fcc879a854add85bf738524616ff94d715 100644 (file)
@@ -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 */