Browse Source

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

Daniel-Constantin Mierla 5 years ago
parent
commit
b5816caeac
1 changed files with 3 additions and 4 deletions
  1. 3 4
      src/modules/textopsx/textopsx.c

+ 3 - 4
src/modules/textopsx/textopsx.c

@@ -352,11 +352,10 @@ static int keep_hf_helper(sip_msg_t *msg, regex_t *re)
 				return -1;
 			}
 		} else {
-			c = hf->name.s[hf->name.len];
-			hf->name.s[hf->name.len] = '\0';
+			STR_VTOZ(hf->name.s[hf->name.len], c);
 			if(regexec(re, hf->name.s, 1, &pmatch, 0) != 0) {
 				/* no match => remove */
-				hf->name.s[hf->name.len] = c;
+				STR_ZTOV(hf->name.s[hf->name.len], c);
 				l = del_lump(msg, hf->name.s - msg->buf, hf->len, 0);
 				if(l == 0) {
 					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)
 					return -1;
 				}
 			} else {
-				hf->name.s[hf->name.len] = c;
+				STR_ZTOV(hf->name.s[hf->name.len], c);
 			}
 		}
 	}