X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fconf.c;h=3f81877bf405e1d4ca35491df127a86f1e947b0a;hb=f7f7d8b15e12471c95bbd291195e83c5126a0631;hp=58d7b6d30e94b4975aa016ed697bf39340bcdfd7;hpb=26203e250433b846118be1b2e236bf2541aa260d;p=tinc 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)) {