From: Arran Cudbard-Bell Date: Tue, 6 Apr 2021 15:42:38 +0000 (+0100) Subject: Don't pass PRESENTATION format string data into json-c X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=281c4e3a6191dcce58201f6e16bf9603422bddb0;p=thirdparty%2Ffreeradius-server.git Don't pass PRESENTATION format string data into json-c Else we'll get all kinds of horrible double escaping --- diff --git a/src/lib/json/json.c b/src/lib/json/json.c index 8467070248..4331340af1 100644 --- a/src/lib/json/json.c +++ b/src/lib/json/json.c @@ -212,12 +212,18 @@ json_object *json_object_from_value_box(TALLOC_CTX *ctx, fr_value_box_t const *d fr_value_box_aprint(ctx, &p, data, NULL); if (!p) return NULL; - obj = json_object_new_string(p); + obj = json_object_new_string_len(p, talloc_array_length(p) - 1); talloc_free(p); return obj; } + case FR_TYPE_STRING: + return json_object_new_string_len(data->vb_strvalue, data->vb_length); + + case FR_TYPE_OCTETS: + return json_object_new_string_len((char *)data->vb_octets, data->vb_length); + case FR_TYPE_BOOL: return json_object_new_boolean(data->vb_uint8);