From: Guus Sliepen Date: Mon, 26 Aug 2019 09:22:53 +0000 (+0200) Subject: Add a missing check for a pathname being too long. X-Git-Tag: release-1.0.36~1 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=fbf9a88fdda1a1ccde68059001448ebeba7884f5;p=tinc Add a missing check for a pathname being too long. --- diff --git a/src/conf.c b/src/conf.c index 58d7b6d3..3f81877b 100644 --- a/src/conf.c +++ b/src/conf.c @@ -467,9 +467,14 @@ static void disable_old_keys(const char *filename) { return; } - snprintf(tmpfile, sizeof(tmpfile), "%s.tmp", filename); + int len = snprintf(tmpfile, sizeof(tmpfile), "%s.tmp", filename); - w = fopen(tmpfile, "w"); + if(len < 0 || len >= PATH_MAX) { + fprintf(stderr, "Pathname too long: %s.tmp\n", filename); + w = NULL; + } else { + w = fopen(tmpfile, "w"); + } while(fgets(buf, sizeof(buf), r)) { if(!strncmp(buf, "-----BEGIN RSA", 14)) {