[sr-dev] git:master:f6a1f96a: xcap_server: use new search function to avoid zero-ending swapping

Daniel-Constantin Mierla miconda at gmail.com
Wed Oct 28 08:54:59 CET 2020


Module: kamailio
Branch: master
Commit: f6a1f96af518ec10b09c4395166943a39eea19dd
URL: https://github.com/kamailio/kamailio/commit/f6a1f96af518ec10b09c4395166943a39eea19dd

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-10-28T08:27:37+01:00

xcap_server: use new search function to avoid zero-ending swapping

---

Modified: src/modules/xcap_server/xcap_server.c

---

Diff:  https://github.com/kamailio/kamailio/commit/f6a1f96af518ec10b09c4395166943a39eea19dd.diff
Patch: https://github.com/kamailio/kamailio/commit/f6a1f96af518ec10b09c4395166943a39eea19dd.patch

---

diff --git a/src/modules/xcap_server/xcap_server.c b/src/modules/xcap_server/xcap_server.c
index 5c1ca9004b..20bb585e3a 100644
--- a/src/modules/xcap_server/xcap_server.c
+++ b/src/modules/xcap_server/xcap_server.c
@@ -304,15 +304,14 @@ int xcaps_xpath_hack(str *buf, int type)
 {
 	char *match;
 	char *repl;
-	char c;
 	char *p;
 	char *start;
+	char *end;
 
 	if(buf==NULL || buf->len <=10)
 		return 0;
 
-	if(type==0)
-	{
+	if(type==0) {
 		match = " xmlns=";
 		repl  = " x____=";
 	} else {
@@ -321,12 +320,11 @@ int xcaps_xpath_hack(str *buf, int type)
 	}
 
 	start = buf->s;
-	STR_VTOZ(buf->s[buf->len-1], c);
-	while((start < buf->s + buf->len - 10) && (p = strstr(start, match))!=NULL) {
+	end = buf->s + buf->len - 10;
+	while((p = stre_search_strz(start, end, match))!=NULL) {
 		memcpy(p, repl, 7);
 		start = p + 7;
 	}
-	STR_ZTOV(buf->s[buf->len-1], c);
 	return 0;
 }
 




More information about the sr-dev mailing list