Fix a problem in the virtual host address compare code which caused

duplicated host entries in /etc/ftphosts not to be folded. Make sure
we exit the loop on a match.

PR:		bin/19390
This commit is contained in:
David Nugent 2000-06-26 05:36:09 +00:00
parent 34b4610b7b
commit b535a9bf12

View File

@ -643,7 +643,7 @@ inithosts()
hrp->next = NULL;
thishost = firsthost = lhrp = hrp;
if ((fp = fopen(_PATH_FTPHOSTS, "r")) != NULL) {
int addrsize, error;
int addrsize, error, gothost;
void *addr;
struct hostent *hp;
@ -670,9 +670,9 @@ inithosts()
if (error != NULL)
continue;
for (ai = res; ai != NULL && ai->ai_addr != NULL;
ai = ai->ai_next)
{
ai = ai->ai_next) {
gothost = 0;
for (hrp = firsthost; hrp != NULL; hrp = hrp->next) {
struct addrinfo *hi;
@ -681,8 +681,12 @@ inithosts()
if (hi->ai_addrlen == ai->ai_addrlen &&
memcmp(hi->ai_addr,
ai->ai_addr,
ai->ai_addr->sa_len) == 0)
ai->ai_addr->sa_len) == 0) {
gothost++;
break;
}
if (gothost)
break;
}
if (hrp == NULL) {
if ((hrp = malloc(sizeof(struct ftphost))) == NULL)
@ -793,8 +797,7 @@ selecthost(su)
port = su->su_port;
su->su_port = 0;
while (hrp != NULL) {
for (hi = hrp->hostinfo; hi != NULL; hi = hi->ai_next)
{
for (hi = hrp->hostinfo; hi != NULL; hi = hi->ai_next) {
if (memcmp(su, hi->ai_addr, hi->ai_addrlen) == 0) {
thishost = hrp;
break;
@ -809,8 +812,8 @@ selecthost(su)
break;
}
#endif
}
hrp = hrp->next;
}
hrp = hrp->next;
}
su->su_port = port;
/* setup static variables as appropriate */