From: Guus Sliepen Date: Sun, 27 Mar 2022 18:56:48 +0000 (+0200) Subject: Fix compiler warning. X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=b13e1a3c1f7252cda5ab95166d9f2d578983471f;p=tinc Fix compiler warning. Quash a compiler warning by checking the result of snprintf() and handling truncation. --- diff --git a/src/tincctl.c b/src/tincctl.c index a3978bcc..0e7d083f 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -1894,7 +1894,11 @@ static int cmd_config(int argc, char *argv[]) { char filename[PATH_MAX]; if(node) { - snprintf(filename, sizeof(filename), "%s" SLASH "%s", hosts_dir, node); + if((size_t)snprintf(filename, sizeof(filename), "%s" SLASH "%s", hosts_dir, node) >= sizeof(filename)) { + fprintf(stderr, "Filename too long: %s" SLASH "%s\n", hosts_dir, node); + free(node); + return 1; + } if(node != line) { free(node);