summaryrefslogtreecommitdiffstats
path: root/libexec/ftpd
diff options
context:
space:
mode:
authordavidn <davidn@FreeBSD.org>2000-06-26 05:36:09 +0000
committerdavidn <davidn@FreeBSD.org>2000-06-26 05:36:09 +0000
commit1f6b02c5a30aeb0ad40e2c490bd13805890ab99c (patch)
treebf9a8bcd0ca659f8c3da98883a717747d1261578 /libexec/ftpd
parentc85586d6d2716b5b5bef62f1a9a705298f17021f (diff)
downloadFreeBSD-src-1f6b02c5a30aeb0ad40e2c490bd13805890ab99c.zip
FreeBSD-src-1f6b02c5a30aeb0ad40e2c490bd13805890ab99c.tar.gz
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
Diffstat (limited to 'libexec/ftpd')
-rw-r--r--libexec/ftpd/ftpd.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index deea1b9..6c65028 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -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 */
OpenPOWER on IntegriCloud