X-Git-Url: http://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fconf.c;h=3f81877bf405e1d4ca35491df127a86f1e947b0a;hb=fbf9a88fdda1a1ccde68059001448ebeba7884f5;hp=03887991cdc5bc80908ff124523b3dd3234ba895;hpb=99763e34d52fcfe76b0bb9c7f3a17ace51cfdbfc;p=tinc diff --git a/src/conf.c b/src/conf.c index 03887991..3f81877b 100644 --- a/src/conf.c +++ b/src/conf.c @@ -81,18 +81,9 @@ config_t *new_config(void) { } void free_config(config_t *cfg) { - if(cfg->variable) { - free(cfg->variable); - } - - if(cfg->value) { - free(cfg->value); - } - - if(cfg->file) { - free(cfg->file); - } - + free(cfg->variable); + free(cfg->value); + free(cfg->file); free(cfg); } @@ -476,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)) {