@@ -1666,7 +1666,7 @@ static char * process_appl_cmd(request_rec *r, char **ptr, int status, int *errt
1666
1666
1667
1667
int i = 0 ;
1668
1668
hostinfo_t hostinfo ;
1669
- hostinfo_t * host ;
1669
+ hostinfo_t * host = NULL ;
1670
1670
char * p_tmp ;
1671
1671
1672
1672
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
1748
1748
return (process_node_cmd (r , status , errtype , node ));
1749
1749
}
1750
1750
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
+ */
1752
1754
hostinfo .node = node -> mess .id ;
1755
+ hostinfo .id = 0 ;
1753
1756
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 {
1764
1771
hostinfo .host [0 ] = '\0' ;
1772
+ }
1765
1773
1766
- hostinfo .id = 0 ;
1767
- host = read_host (hoststatsmem , & hostinfo );
1768
1774
if (host == NULL ) {
1769
1775
/* If REMOVE ignores it */
1770
1776
if (status == REMOVE )
0 commit comments