@@ -2075,7 +2075,7 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty
20752075
20762076 int i = 0 ;
20772077 hostinfo_t hostinfo ;
2078- hostinfo_t * host ;
2078+ hostinfo_t * host = NULL ;
20792079 char * err_msg ;
20802080
20812081 memset (& nodeinfo .mess , '\0' , sizeof (nodeinfo .mess ));
@@ -2149,22 +2149,29 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty
21492149 return ret ;
21502150 }
21512151
2152- /* Read the ID of the virtual host corresponding to the first Alias */
2152+ /* Go through the provided Aliases, the first Alias that matches an existing host gets used
2153+ * otherwise, a new host will be created
2154+ */
21532155 hostinfo .node = node -> mess .id ;
2156+ hostinfo .id = 0 ;
21542157 if (vhost -> host != NULL ) {
2155- char * s = hostinfo .host ;
2156- unsigned j = 1 ;
2157- strncpy (hostinfo .host , vhost -> host , HOSTALIASZ );
2158- while (* s != '\0' && * s != ',' && j < sizeof (hostinfo .host )) {
2159- j ++ ;
2160- s ++ ;
2158+ int start = 0 ;
2159+ i = 0 ;
2160+ while (host == NULL && i + start < strlen (vhost -> host )) {
2161+ while (vhost -> host [start + i ] != ',' && vhost -> host [start + i ] != '\0' ) {
2162+ i ++ ;
2163+ }
2164+
2165+ strncpy (hostinfo .host , vhost -> host + start , i );
2166+ hostinfo .host [i ] = '\0' ;
2167+ host = read_host (hoststatsmem , & hostinfo );
2168+ start = start + i + 1 ;
2169+ i = 0 ;
21612170 }
2162- * s = '\0' ;
21632171 } else {
21642172 hostinfo .host [0 ] = '\0' ;
21652173 }
2166- hostinfo .id = 0 ;
2167- host = read_host (hoststatsmem , & hostinfo );
2174+
21682175 if (host == NULL ) {
21692176 int vid , size , * id ;
21702177
0 commit comments