From 537a822150d19e1b90f0ba59171ee088d95a71cf Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Tue, 27 Nov 2018 22:12:51 +0100 Subject: [PATCH] fix building uri closes #381 --- be-http.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/be-http.c b/be-http.c index 7fed1dea..afb40638 100644 --- a/be-http.c +++ b/be-http.c @@ -132,12 +132,11 @@ static int http_post(void *handle, char *uri, const char *clientid, const char * return BACKEND_ERROR; } - // enable the https - if (strcmp(conf->with_tls, "true") == 0){ - sprintf(url, "https://%s:%d%s", conf->hostname, conf->port, uri); - }else{ - sprintf(url, "http://%s:%d%s", conf->hostname, conf->port, uri); - } + snprintf(url, sizeof(url), "%s://%s:%d/%s", + strcmp(conf->with_tls, "true") == 0 ? "https" : "http", + conf->hostname ? conf->hostname : "127.0.0.1", + conf->port, + uri); char* escaped_username = curl_easy_escape(curl, username, 0); char* escaped_password = curl_easy_escape(curl, password, 0);