From 2f422c03925e82bf88b05da823813073a985b0e5 Mon Sep 17 00:00:00 2001 From: "fergus.henderson@gmail.com" Date: Tue, 10 Apr 2012 17:22:14 +0000 Subject: =?UTF-8?q?Apply=20patch=20from=20J=C3=A9r=C3=A9mie=20Koenig=20:=20Fix=20for=20:=20Distcc=20fails=20to=20build=20o?= =?UTF-8?q?n=20hurd-i386=20because=20it=20relies=20on=20PATH=5FMAX=20being?= =?UTF-8?q?=20defined.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://distcc.googlecode.com/svn/trunk@765 01de4be4-8c4a-0410-9132-4925637da917 --- src/stringmap.c | 4 ++++ src/zeroconf.c | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/stringmap.c b/src/stringmap.c index 8bf2eab..2fa2a59 100644 --- a/src/stringmap.c +++ b/src/stringmap.c @@ -32,6 +32,10 @@ #define NULL 0 #endif +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif + /* Load the given list of strings into the key/value map. * The key for each string is the numFinalWordsToMatch of the string; * the value for each string is the entire string. diff --git a/src/zeroconf.c b/src/zeroconf.c index 5b70566..652cc1d 100644 --- a/src/zeroconf.c +++ b/src/zeroconf.c @@ -540,7 +540,7 @@ static int get_zeroconf_dir(char **dir_ret) { /* Get the host list from zeroconf */ int dcc_zeroconf_add_hosts(struct dcc_hostdef **ret_list, int *ret_nhosts, int n_slots, struct dcc_hostdef **ret_prev) { - char host_file[PATH_MAX], lock_file[PATH_MAX], *s = NULL; + char *host_file = NULL, *lock_file = NULL, *s = NULL; int lock_fd = -1, host_fd = -1; int fork_daemon = 0; int r = -1; @@ -552,8 +552,13 @@ int dcc_zeroconf_add_hosts(struct dcc_hostdef **ret_list, int *ret_nhosts, int n goto finish; } - snprintf(lock_file, sizeof(lock_file), "%s/lock", dir); - snprintf(host_file, sizeof(host_file), "%s/hosts", dir); + lock_file = malloc(strlen(dir) + sizeof("/lock")); + assert(lock_file); + sprintf(lock_file, "%s/lock", dir); + + host_file = malloc(strlen(dir) + sizeof("/hosts")); + assert(host_file); + sprintf(host_file, "%s/hosts", dir); /* Open lock file */ if ((lock_fd = open(lock_file, O_RDWR|O_CREAT, 0666)) < 0) { @@ -659,6 +664,8 @@ finish: close(host_fd); } + free(lock_file); + free(host_file); free(s); return r; -- cgit v1.2.1