Skip to content

Commit

Permalink
xcap_server: check before going to the end of the buffer
Browse files Browse the repository at this point in the history
- use marcros to set and restore char for ending 0

(cherry picked from commit 6ce5c0b)
  • Loading branch information
miconda committed Aug 26, 2020
1 parent c98d9e8 commit 4aeb071
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/modules/xcap_server/xcap_server.c
Expand Up @@ -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;
}

Expand Down

0 comments on commit 4aeb071

Please sign in to comment.