From ecf1fcc84594b09ed2d61e3677cd8e62bd897ccb Mon Sep 17 00:00:00 2001 From: Max Lv Date: Tue, 10 Jan 2017 21:57:38 +0800 Subject: [PATCH] Fix #1059 --- src/manager.c | 4 +--- src/plugin.c | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/manager.c b/src/manager.c index 6f4c514f..e32f43c1 100644 --- a/src/manager.c +++ b/src/manager.c @@ -319,7 +319,7 @@ create_and_bind(const char *host, const char *port, int protocol) { struct addrinfo hints; struct addrinfo *result, *rp, *ipv4v6bindall; - int s, listen_sock, is_port_reuse; + int s, listen_sock = -1, is_port_reuse = 0; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */ @@ -356,8 +356,6 @@ create_and_bind(const char *host, const char *port, int protocol) } } - is_port_reuse = 0; - for (/*rp = result*/; rp != NULL; rp = rp->ai_next) { listen_sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); if (listen_sock == -1) { diff --git a/src/plugin.c b/src/plugin.c index ff683acc..b5703611 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -101,8 +101,13 @@ start_plugin(const char *plugin, env = cork_env_clone_current(); const char *path = cork_env_get(env, "PATH"); if (path != NULL) { +#ifdef __GLIBC__ char *cwd = get_current_dir_name(); if (cwd) { +#else + char cwd[PATH_MAX]; + if (!getcwd(cwd, PATH_MAX)) { +#endif size_t path_len = strlen(path) + strlen(cwd) + 2; new_path = ss_malloc(path_len); snprintf(new_path, path_len, "%s:%s", cwd, path);