Skip to content

Commit

Permalink
dispatcher: use safer macros for temporarily making zero-ending strings
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Apr 29, 2020
1 parent d815a2c commit 28f4cab
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/modules/dispatcher/dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,23 +420,16 @@ ds_dest_t *pack_dest(str iuri, int flags, int priority, str *attrs)
} else if(dp->attrs.socket.s && dp->attrs.socket.len > 0) {
/* parse_phostport(...) expects 0-terminated string
* - after socket parameter is either ';' or '\0' */
if(dp->attrs.socket.s[dp->attrs.socket.len] != '\0') {
c = dp->attrs.socket.s[dp->attrs.socket.len];
dp->attrs.socket.s[dp->attrs.socket.len] = '\0';
}
STR_VTOZ(dp->attrs.socket.s[dp->attrs.socket.len], c);
if(parse_phostport(
dp->attrs.socket.s, &host.s, &host.len, &port, &proto)
!= 0) {
LM_ERR("bad socket <%.*s>\n", dp->attrs.socket.len,
dp->attrs.socket.s);
if(c != 0) {
dp->attrs.socket.s[dp->attrs.socket.len] = c;
}
STR_ZTOV(dp->attrs.socket.s[dp->attrs.socket.len], c);
goto err;
}
if(c != 0) {
dp->attrs.socket.s[dp->attrs.socket.len] = c;
}
STR_ZTOV(dp->attrs.socket.s[dp->attrs.socket.len], c);
dp->sock = grep_sock_info(&host, (unsigned short)port, proto);
if(dp->sock == 0) {
LM_ERR("non-local socket <%.*s>\n", dp->attrs.socket.len,
Expand Down

0 comments on commit 28f4cab

Please sign in to comment.