From bcc5ca1a463b5aa3f62c11a2e518e2afc1d5c877 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 16 Mar 2015 22:47:23 +1100 Subject: [PATCH] Properly encode error messages in API responses --- src/generator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/generator.c b/src/generator.c index fd90be00..5d36f22c 100644 --- a/src/generator.c +++ b/src/generator.c @@ -2094,7 +2094,7 @@ static void send_sublist(gdata_t *gdata, const int sockd, const char *buf) array_val = json_array(); - val = json_loads(buf, 0, NULL); + val = json_loads(buf, 0, &err_val); if (unlikely(!val)) { val = json_encode_errormsg(&err_val); goto out; @@ -2140,7 +2140,7 @@ static void parse_addproxy(ckpool_t *ckp, gdata_t *gdata, const int sockd, const json_t *val = NULL; int id; - val = json_loads(buf, 0, NULL); + val = json_loads(buf, 0, &err_val); if (unlikely(!val)) { val = json_encode_errormsg(&err_val); goto out; @@ -2150,7 +2150,7 @@ static void parse_addproxy(ckpool_t *ckp, gdata_t *gdata, const int sockd, const json_get_string(&pass, val, "pass"); json_decref(val); if (unlikely(!url || !auth || !pass)) { - LOGWARNING("Failed to decode url/auth/pass in addproxy %s", buf); + val = json_errormsg("Failed to decode url/auth/pass in addproxy %s", buf); goto out; }