From cc599727c767313c9f198b3d2c7c522ee54a10ec Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 12 Jul 2022 19:05:52 +0200 Subject: [PATCH] rest_api: Fix cbs.data_user_len not set in 'payload_encoded' This is later used in cbcmsg_to_cbsp(), but only set for type 'payload_decoded' in parse_payload_decoded(). Change-Id: I519cf300cd01e8c2728babeaa77b8486f47115be --- src/rest_api.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/rest_api.c b/src/rest_api.c index a779f3d..e596b77 100644 --- a/src/rest_api.c +++ b/src/rest_api.c @@ -317,7 +317,7 @@ static int json2payload(struct smscb_message *out, json_t *in, const char **errs if ((jtmp = json_object_get(in, "payload_encoded"))) { json_t *jpage_arr, *jpage; - int i, dcs, num_pages; + int i, dcs, num_pages, len; out->is_etws = false; /* Data Coding Scheme */ @@ -340,6 +340,7 @@ static int json2payload(struct smscb_message *out, json_t *in, const char **errs return -EINVAL; } out->cbs.num_pages = num_pages; + out->cbs.data_user_len = 0; json_array_foreach(jpage_arr, i, jpage) { const char *hexstr; if (!json_is_string(jpage)) { @@ -351,10 +352,12 @@ static int json2payload(struct smscb_message *out, json_t *in, const char **errs *errstr = "'pages' array must contain strings up to 88 hex nibbles"; return -EINVAL; } - if (osmo_hexparse(hexstr, out->cbs.data[i], sizeof(out->cbs.data[i])) < 0) { + len = osmo_hexparse(hexstr, out->cbs.data[i], sizeof(out->cbs.data[i])); + if (len < 0) { *errstr = "'pages' array must contain hex strings"; return -EINVAL; } + out->cbs.data_user_len += len; } return 0; } else if ((jtmp = json_object_get(in, "payload_decoded"))) {