@@ -1666,7 +1666,7 @@ static char * process_appl_cmd(request_rec *r, char **ptr, int status, int *errt
16661666
16671667 int i = 0 ;
16681668 hostinfo_t hostinfo ;
1669- hostinfo_t * host ;
1669+ hostinfo_t * host = NULL ;
16701670 char * p_tmp ;
16711671
16721672 memset (& nodeinfo .mess , '\0' , sizeof (nodeinfo .mess ));
@@ -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