X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fconf.c;h=1c250d7bc3c76f4846d6de58351936a2cf48b6a5;hp=997a05e82e9aab307f83154e5ab3ed84861d0e11;hb=acd018074972f9c13ffecffb618f799d914bbe97;hpb=c34eff55553c8cf34bb3bdefa619c27ac193485b diff --git a/src/conf.c b/src/conf.c index 997a05e8..1c250d7b 100644 --- a/src/conf.c +++ b/src/conf.c @@ -485,8 +485,9 @@ static void disable_old_keys(const char *filename) { FILE *ask_and_open(const char *filename, const char *what) { FILE *r; - char *directory; + char directory[PATH_MAX]; char line[PATH_MAX]; + char abspath[PATH_MAX]; const char *fn; /* Check stdin and stdout */ @@ -520,12 +521,9 @@ FILE *ask_and_open(const char *filename, const char *what) { if(fn[0] != '/') { #endif /* The directory is a relative path or a filename. */ - char *p; - - directory = get_current_dir_name(); - xasprintf(&p, "%s/%s", directory, fn); - free(directory); - fn = p; + getcwd(directory, sizeof directory); + snprintf(abspath, sizeof abspath, "%s/%s", directory, fn); + fn = abspath; } umask(0077); /* Disallow everything for group and other */