From b13e1a3c1f7252cda5ab95166d9f2d578983471f Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 27 Mar 2022 20:56:48 +0200 Subject: [PATCH] Fix compiler warning. Quash a compiler warning by checking the result of snprintf() and handling truncation. --- src/tincctl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); -- 2.20.1