Module: kamailio
Branch: master
Commit: 6ce5c0bdf136ecffd7917f2d60093e1b2c49fa54
URL:
https://github.com/kamailio/kamailio/commit/6ce5c0bdf136ecffd7917f2d60093e1…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-08-02T17:08:49+02:00
xcap_server: check before going to the end of the buffer
- use marcros to set and restore char for ending 0
---
Modified: src/modules/xcap_server/xcap_server.c
---
Diff:
https://github.com/kamailio/kamailio/commit/6ce5c0bdf136ecffd7917f2d60093e1…
Patch:
https://github.com/kamailio/kamailio/commit/6ce5c0bdf136ecffd7917f2d60093e1…
---
diff --git a/src/modules/xcap_server/xcap_server.c
b/src/modules/xcap_server/xcap_server.c
index ec4a3d1975..1556aa14b9 100644
--- a/src/modules/xcap_server/xcap_server.c
+++ b/src/modules/xcap_server/xcap_server.c
@@ -321,14 +321,12 @@ int xcaps_xpath_hack(str *buf, int type)
}
start = buf->s;
- c = buf->s[buf->len-1];
- buf->s[buf->len-1] = '\0';
- while((p = strstr(start, match))!=NULL)
- {
+ STR_VTOZ(buf->s[buf->len-1], c);
+ while((start < buf->s + buf->len - 8) && (p = strstr(start,
match))!=NULL) {
memcpy(p, repl, 7);
start = p + 7;
}
- buf->s[buf->len-1] = c;
+ STR_ZTOV(buf->s[buf->len-1], c);
return 0;
}