Skip to content
This repository has been archived by the owner on Mar 12, 2019. It is now read-only.

Commit

Permalink
fix length of url
Browse files Browse the repository at this point in the history
	closes #387
  • Loading branch information
jpmens committed Dec 10, 2018
1 parent 4f67cfb commit 0fb39cc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions be-http.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static int http_post(void *handle, char *uri, const char *clientid, const char *
struct http_backend *conf = (struct http_backend *)handle;
CURL *curl;
struct curl_slist *headerlist=NULL;
int re;
int re, urllen = 0;
int respCode = 0;
int ok = BACKEND_DEFER;
char *url;
Expand Down Expand Up @@ -126,14 +126,15 @@ static int http_post(void *handle, char *uri, const char *clientid, const char *

//_log(LOG_NOTICE, "u=%s p=%s t=%s acc=%d", username, password, topic, acc);

url = (char *)malloc(strlen(conf->hostname) + strlen(uri) + 20);
urllen = strlen(conf->hostname) + strlen(uri) + 20;
url = (char *)malloc(urllen);
if (url == NULL) {
_fatal("ENOMEM");
return BACKEND_ERROR;
}

// uri begins with a slash
snprintf(url, sizeof(url), "%s://%s:%d%s",
snprintf(url, urllen, "%s://%s:%d%s",
strcmp(conf->with_tls, "true") == 0 ? "https" : "http",
conf->hostname ? conf->hostname : "127.0.0.1",
conf->port,
Expand Down

0 comments on commit 0fb39cc

Please sign in to comment.