Skip to content

Commit bcda1b1

Browse files
committed
Improve handling of overlapping aliases in APP commands
Resolves MODCLUSTER-824
1 parent 2577249 commit bcda1b1

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

native/mod_manager/mod_manager.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,23 +1748,29 @@ static char * process_appl_cmd(request_rec *r, char **ptr, int status, int *errt
17481748
return (process_node_cmd(r, status, errtype, node));
17491749
}
17501750

1751-
/* Read the ID of the virtual host corresponding to the first Alias */
1751+
/* Go through the provided Aliases, the first Alias that matches an existing host gets used
1752+
* otherwise, a new host will be created
1753+
*/
17521754
hostinfo.node = node->mess.id;
1755+
hostinfo.id = 0;
17531756
if (vhost->host != NULL) {
1754-
char *s = hostinfo.host;
1755-
int j = 1;
1756-
strncpy(hostinfo.host, vhost->host, sizeof(hostinfo.host));
1757-
hostinfo.host[sizeof(hostinfo.host)-1] = '\0';
1758-
while (*s != ',' && j<sizeof(hostinfo.host)) {
1759-
j++;
1760-
s++;
1761-
}
1762-
*s = '\0';
1763-
} else
1757+
int start = 0;
1758+
i = 0;
1759+
while (host == NULL && i + start < strlen(vhost->host)) {
1760+
while (vhost->host[start+i] != ',' && vhost->host[start+i] != '\0') {
1761+
i++;
1762+
}
1763+
1764+
strncpy(hostinfo.host, vhost->host + start, i);
1765+
hostinfo.host[i] = '\0';
1766+
host = read_host(hoststatsmem, &hostinfo);
1767+
start = start + i + 1;
1768+
i = 0;
1769+
}
1770+
} else {
17641771
hostinfo.host[0] = '\0';
1772+
}
17651773

1766-
hostinfo.id = 0;
1767-
host = read_host(hoststatsmem, &hostinfo);
17681774
if (host == NULL) {
17691775
/* If REMOVE ignores it */
17701776
if (status == REMOVE)

0 commit comments

Comments
 (0)