Module: kamailio
Branch: 5.2
Commit: 667ef53f1d296950f352c6e89da08b22695d87bc
URL:
https://github.com/kamailio/kamailio/commit/667ef53f1d296950f352c6e89da08b2…
Author: Henning Westerholt <hw(a)skalatan.de>
Committer: Henning Westerholt <hw(a)skalatan.de>
Date: 2020-10-02T18:32:56Z
Revert "jansson: use the core macros for ending string value with '\0' and to
restore"
This reverts commit 61255b01f88ea904bf5694f834a5b2aec7398c69.
---
Modified: src/modules/jansson/jansson_funcs.c
---
Diff:
https://github.com/kamailio/kamailio/commit/667ef53f1d296950f352c6e89da08b2…
Patch:
https://github.com/kamailio/kamailio/commit/667ef53f1d296950f352c6e89da08b2…
---
diff --git a/src/modules/jansson/jansson_funcs.c b/src/modules/jansson/jansson_funcs.c
index a5f8b1f6fd..7eceae4e96 100644
--- a/src/modules/jansson/jansson_funcs.c
+++ b/src/modules/jansson/jansson_funcs.c
@@ -26,7 +26,6 @@
#include "../../core/mod_fix.h"
#include "../../core/lvalue.h"
-#include "../../core/str.h"
#include "jansson_path.h"
#include "jansson_funcs.h"
@@ -34,13 +33,13 @@
int janssonmod_get_helper(sip_msg_t* msg, str *path_s, str *src_s, pv_spec_t *dst_pv)
{
- char c;
+
pv_value_t dst_val;
json_t* json = NULL;
json_error_t parsing_error;
- STR_VTOZ(src_s->s[src_s->len], c);
+
json = json_loads(src_s->s, JSON_REJECT_DUPLICATES, &parsing_error);
- STR_ZTOV(src_s->s[src_s->len], c);
+
if(!json) {
ERR("failed to parse json: %.*s\n", src_s->len, src_s->s);
ERR("json error at line %d, col %d: %s\n",
@@ -99,7 +98,7 @@ int janssonmod_set(unsigned int append, struct sip_msg* msg, char*
type_in,
str type_s;
str value_s;
str path_s;
- char c;
+
pv_spec_t* result_pv;
pv_value_t result_val;
@@ -127,11 +126,14 @@ int janssonmod_set(unsigned int append, struct sip_msg* msg, char*
type_in,
result_val.rs.len = strlen("{}");
}
+/*
+ ALERT("type is: %.*s\n", type_s.len, type_s.s);
+ ALERT("path is: %.*s\n", path_s.len, path_s.s);
+ ALERT("value is: %.*s\n", value_s.len, value_s.s);
+ ALERT("result is: %.*s\n", result_val.rs.len, result_val.rs.s);
+*/
- LM_DBG("type is: %.*s\n", type_s.len, type_s.s);
- LM_DBG("path is: %.*s\n", path_s.len, path_s.s);
- LM_DBG("value is: %.*s\n", value_s.len, value_s.s);
- LM_DBG("result is: %.*s\n", result_val.rs.len, result_val.rs.s);
+ char* result = result_val.rs.s;
json_t* result_json = NULL;
json_t* value = NULL;
@@ -141,18 +143,14 @@ int janssonmod_set(unsigned int append, struct sip_msg* msg, char*
type_in,
/* check the type */
if(STR_EQ_STATIC(type_s, "object") || STR_EQ_STATIC(type_s,
"obj")){
- STR_VTOZ(value_s.s[value_s.len], c);
value = json_loads(value_s.s, JSON_REJECT_DUPLICATES, &parsing_error);
- STR_ZTOV(value_s.s[value_s.len], c);
if(value && !json_is_object(value)) {
ERR("value to add is not an object - \"%s\"\n", path_s.s);
goto fail;
}
}else if(STR_EQ_STATIC(type_s, "array")) {
- STR_VTOZ(value_s.s[value_s.len], c);
value = json_loads(value_s.s, JSON_REJECT_DUPLICATES, &parsing_error);
- STR_ZTOV(value_s.s[value_s.len], c);
if(value && !json_is_array(value)) {
ERR("value to add is not an array - \"%s\"\n", path_s.s);
goto fail;
@@ -213,9 +211,9 @@ int janssonmod_set(unsigned int append, struct sip_msg* msg, char*
type_in,
}
char* path = path_s.s;
- STR_VTOZ(result_val.rs.s[result_val.rs.len], c);
- result_json = json_loads(result_val.rs.s, JSON_REJECT_DUPLICATES, &parsing_error);
- STR_ZTOV(result_val.rs.s[result_val.rs.len], c);
+
+ result_json = json_loads(result, JSON_REJECT_DUPLICATES, &parsing_error);
+
if(!result_json) {
ERR("result has json error at line %d: %s\n",
parsing_error.line, parsing_error.text);
@@ -242,7 +240,6 @@ int janssonmod_set(unsigned int append, struct sip_msg* msg, char*
type_in,
int janssonmod_array_size(struct sip_msg* msg, char* path_in, char* src_in, char* dst)
{
- char c;
str src_s;
str path_s;
pv_spec_t *dst_pv;
@@ -262,9 +259,9 @@ int janssonmod_array_size(struct sip_msg* msg, char* path_in, char*
src_in, char
json_t* json = NULL;
json_error_t parsing_error;
- STR_VTOZ(src_s.s[src_s.len], c);
+
json = json_loads(src_s.s, JSON_REJECT_DUPLICATES, &parsing_error);
- STR_ZTOV(src_s.s[src_s.len], c);
+
if(!json) {
ERR("json error at line %d: %s\n",
parsing_error.line, parsing_error.text);