Browse code

textopsx: use safer macros for temporarily making zero-ending strings

Daniel-Constantin Mierla authored on 01/05/2020 06:53:56
Showing 1 changed files
... ...
@@ -352,11 +352,10 @@ static int keep_hf_helper(sip_msg_t *msg, regex_t *re)
352 352
 				return -1;
353 353
 			}
354 354
 		} else {
355
-			c = hf->name.s[hf->name.len];
356
-			hf->name.s[hf->name.len] = '\0';
355
+			STR_VTOZ(hf->name.s[hf->name.len], c);
357 356
 			if(regexec(re, hf->name.s, 1, &pmatch, 0) != 0) {
358 357
 				/* no match => remove */
359
-				hf->name.s[hf->name.len] = c;
358
+				STR_ZTOV(hf->name.s[hf->name.len], c);
360 359
 				l = del_lump(msg, hf->name.s - msg->buf, hf->len, 0);
361 360
 				if(l == 0) {
362 361
 					LM_ERR("cannot remove header [%.*s]\n", hf->name.len,
... ...
@@ -364,7 +363,7 @@ static int keep_hf_helper(sip_msg_t *msg, regex_t *re)
364 363
 					return -1;
365 364
 				}
366 365
 			} else {
367
-				hf->name.s[hf->name.len] = c;
366
+				STR_ZTOV(hf->name.s[hf->name.len], c);
368 367
 			}
369 368
 		}
370 369
 	}