Browse code

Revert "jansson: use the core macros for ending string value with '\0' and to restore"

This reverts commit 61255b01f88ea904bf5694f834a5b2aec7398c69.

Henning Westerholt authored on 02/10/2020 18:32:56
Showing 1 changed files
... ...
@@ -26,7 +26,6 @@
26 26
 
27 27
 #include "../../core/mod_fix.h"
28 28
 #include "../../core/lvalue.h"
29
-#include "../../core/str.h"
30 29
 
31 30
 #include "jansson_path.h"
32 31
 #include "jansson_funcs.h"
... ...
@@ -34,13 +33,13 @@
34 33
 
35 34
 int janssonmod_get_helper(sip_msg_t* msg, str *path_s, str *src_s, pv_spec_t *dst_pv)
36 35
 {
37
-	char c;
36
+
38 37
 	pv_value_t dst_val;
39 38
 	json_t* json = NULL;
40 39
 	json_error_t parsing_error;
41
-	STR_VTOZ(src_s->s[src_s->len], c);
40
+
42 41
 	json = json_loads(src_s->s, JSON_REJECT_DUPLICATES, &parsing_error);
43
-	STR_ZTOV(src_s->s[src_s->len], c);
42
+
44 43
 	if(!json) {
45 44
 		ERR("failed to parse json: %.*s\n", src_s->len, src_s->s);
46 45
 		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,
99 98
 	str type_s;
100 99
 	str value_s;
101 100
 	str path_s;
102
-	char c;
101
+
103 102
 	pv_spec_t* result_pv;
104 103
 	pv_value_t result_val;
105 104
 
... ...
@@ -127,11 +126,14 @@ int janssonmod_set(unsigned int append, struct sip_msg* msg, char* type_in,
127 126
 		result_val.rs.len = strlen("{}");
128 127
 	}
129 128
 
129
+/*
130
+	ALERT("type is: %.*s\n", type_s.len, type_s.s);
131
+	ALERT("path is: %.*s\n", path_s.len, path_s.s);
132
+	ALERT("value is: %.*s\n", value_s.len, value_s.s);
133
+	ALERT("result is: %.*s\n", result_val.rs.len, result_val.rs.s);
134
+*/
130 135
 
131
-	LM_DBG("type is: %.*s\n", type_s.len, type_s.s);
132
-	LM_DBG("path is: %.*s\n", path_s.len, path_s.s);
133
-	LM_DBG("value is: %.*s\n", value_s.len, value_s.s);
134
-	LM_DBG("result is: %.*s\n", result_val.rs.len, result_val.rs.s);
136
+	char* result = result_val.rs.s;
135 137
 
136 138
 	json_t* result_json = NULL;
137 139
 	json_t* value = NULL;
... ...
@@ -141,18 +143,14 @@ int janssonmod_set(unsigned int append, struct sip_msg* msg, char* type_in,
141 143
 
142 144
 	/* check the type */
143 145
 	if(STR_EQ_STATIC(type_s, "object") || STR_EQ_STATIC(type_s, "obj")){
144
-		STR_VTOZ(value_s.s[value_s.len], c);
145 146
 		value = json_loads(value_s.s, JSON_REJECT_DUPLICATES, &parsing_error);
146
-		STR_ZTOV(value_s.s[value_s.len], c);
147 147
 		if(value && !json_is_object(value)) {
148 148
 			ERR("value to add is not an object - \"%s\"\n", path_s.s);
149 149
 			goto fail;
150 150
 		}
151 151
 
152 152
 	}else if(STR_EQ_STATIC(type_s, "array")) {
153
-		STR_VTOZ(value_s.s[value_s.len], c);
154 153
 		value = json_loads(value_s.s, JSON_REJECT_DUPLICATES, &parsing_error);
155
-		STR_ZTOV(value_s.s[value_s.len], c);
156 154
 		if(value && !json_is_array(value)) {
157 155
 			ERR("value to add is not an array - \"%s\"\n", path_s.s);
158 156
 			goto fail;
... ...
@@ -213,9 +211,9 @@ int janssonmod_set(unsigned int append, struct sip_msg* msg, char* type_in,
213 211
 	}
214 212
 
215 213
 	char* path = path_s.s;
216
-	STR_VTOZ(result_val.rs.s[result_val.rs.len], c);
217
-	result_json = json_loads(result_val.rs.s, JSON_REJECT_DUPLICATES, &parsing_error);
218
-	STR_ZTOV(result_val.rs.s[result_val.rs.len], c);
214
+
215
+	result_json = json_loads(result, JSON_REJECT_DUPLICATES, &parsing_error);
216
+
219 217
 	if(!result_json) {
220 218
 		ERR("result has json error at line %d: %s\n",
221 219
 				parsing_error.line, parsing_error.text);
... ...
@@ -242,7 +240,6 @@ fail:
242 240
 
243 241
 int janssonmod_array_size(struct sip_msg* msg, char* path_in, char* src_in, char* dst)
244 242
 {
245
-	char c;
246 243
 	str src_s;
247 244
 	str path_s;
248 245
 	pv_spec_t *dst_pv;
... ...
@@ -262,9 +259,9 @@ int janssonmod_array_size(struct sip_msg* msg, char* path_in, char* src_in, char
262 259
 
263 260
 	json_t* json = NULL;
264 261
 	json_error_t parsing_error;
265
-	STR_VTOZ(src_s.s[src_s.len], c);
262
+
266 263
 	json = json_loads(src_s.s, JSON_REJECT_DUPLICATES, &parsing_error);
267
-	STR_ZTOV(src_s.s[src_s.len], c);
264
+
268 265
 	if(!json) {
269 266
 		ERR("json error at line %d: %s\n",
270 267
 				parsing_error.line, parsing_error.text);