From 41263c3bbd4af822d0a73d6353d764f321a4a592 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Fri, 17 Feb 2017 13:17:13 +0800 Subject: [PATCH] Fix build on non-GPU targets --- src/plugin.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/plugin.c b/src/plugin.c index 0fb4d658..3564def3 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -173,7 +173,7 @@ static int start_obfsproxy(const char *plugin, cork_exec_add_param(exec, "--data-dir"); buf_size = 20 + strlen(plugin) + strlen(remote_host) + strlen(remote_port) + strlen(local_host) + strlen(local_port); - buf = malloc(buf_size); + buf = ss_malloc(buf_size); snprintf(buf, buf_size, "/tmp/%s_%s:%s_%s:%s", plugin, remote_host, remote_port, local_host, local_port); cork_exec_add_param(exec, buf); @@ -239,12 +239,19 @@ start_plugin(const char *plugin, env = cork_env_clone_current(); current_path = cork_env_get(env, "PATH"); if (current_path != NULL) { +#ifdef _GNU_SOURCE char *cwd = get_current_dir_name(); if (cwd) { +#else + char cwd[PATH_MAX]; + if (!getcwd(cwd, PATH_MAX)) { +#endif new_path_len = strlen(current_path) + strlen(cwd) + 2; new_path = ss_malloc(new_path_len); snprintf(new_path, new_path_len, "%s:%s", cwd, current_path); +#ifdef _GNU_SOURCE free(cwd); +#endif } } if (new_path != NULL)