X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcurl_json.c;h=36cc468b923c1272586bd4df491a511629a97a71;hb=617ab1acea89e0d0be874c6fbaa626ea5ae87c50;hp=251fee8563cb4e865dcb0021cb8d0acb8ec592e0;hpb=104eeb9961455ecf3feeb2d526ad089c2daddfeb;p=collectd.git diff --git a/src/curl_json.c b/src/curl_json.c index 251fee85..36cc468b 100644 --- a/src/curl_json.c +++ b/src/curl_json.c @@ -53,10 +53,10 @@ struct cj_key_s; typedef struct cj_key_s cj_key_t; struct cj_key_s /* {{{ */ { + unsigned long magic; char *path; char *type; char *instance; - unsigned long magic; }; /* }}} */ @@ -549,6 +549,7 @@ static int cj_config_add_key (cj_t *db, /* {{{ */ len = ptr-name; if (len == 0) break; + len = COUCH_MIN(len, sizeof (ent)-1); sstrncpy (ent, name, len+1); if (c_avl_get (tree, ent, (void *) &value) != 0) @@ -858,17 +859,17 @@ static int cj_curl_perform(cj_t *db) /* {{{ */ int status; long rc; char *url; - url = NULL; - curl_easy_getinfo(db->curl, CURLINFO_EFFECTIVE_URL, &url); + url = db->url; status = curl_easy_perform (db->curl); if (status != CURLE_OK) { ERROR ("curl_json plugin: curl_easy_perform failed with status %i: %s (%s)", - status, db->curl_errbuf, (url != NULL) ? url : ""); + status, db->curl_errbuf, url); return (-1); } + curl_easy_getinfo(db->curl, CURLINFO_EFFECTIVE_URL, &url); curl_easy_getinfo(db->curl, CURLINFO_RESPONSE_CODE, &rc); /* The response code is zero if a non-HTTP transport was used. */