From: Etienne Dechamps Date: Sun, 24 May 2015 08:49:16 +0000 (+0100) Subject: Fix invalid pointer use in get_my_hostname(). X-Git-Tag: release-1.1pre12~128 X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=commitdiff_plain;h=9e3adef5cb31cb73fbbbd25d3fce115aac107714 Fix invalid pointer use in get_my_hostname(). clang-3.7 warnings surfaced an actual bug: invitation.c:185:5: error: address of array 'filename' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion] if(filename) { ~~ ^~~~~~~~ The regression was introduced in 3ccdf50beb6b2d3f2730bdc66006b43190537cde. --- diff --git a/src/invitation.c b/src/invitation.c index ed2df88a..415c2377 100644 --- a/src/invitation.c +++ b/src/invitation.c @@ -84,7 +84,7 @@ char *get_my_hostname() { char *port = NULL; char *hostport = NULL; char *name = get_my_name(false); - char filename[PATH_MAX]; + char filename[PATH_MAX] = {0}; // Use first Address statement in own host config file if(check_id(name)) { @@ -182,7 +182,7 @@ again: hostname = xstrdup(line); save: - if(filename) { + if(*filename) { FILE *f = fopen(filename, "a"); if(f) { fprintf(f, "\nAddress = %s\n", hostname);