From owner-freebsd-questions Fri Jun 16 15:37: 9 2000 Delivered-To: freebsd-questions@freebsd.org Received: from false.vmts.ru (false.vmts.ru [212.122.1.9]) by hub.freebsd.org (Postfix) with ESMTP id B529F37BA58 for ; Fri, 16 Jun 2000 15:37:02 -0700 (PDT) (envelope-from isv@false.vmts.ru) Received: from 192.168.10.122 (core.vmts.ru [212.122.1.132]) by false.vmts.ru (8.9.3/8.9.3) with ESMTP id JAA39965 for ; Sat, 17 Jun 2000 09:36:59 +1100 (VLAST) (envelope-from isv@false.vmts.ru) Date: Sat, 17 Jun 2000 09:38:00 +1100 From: isv X-Mailer: The Bat! (v1.35) S/N 1975 Reply-To: isv X-Priority: 3 (Normal) Message-ID: <17401.000617@false.vmts.ru> To: freebsd-questions@FreeBSD.ORG Subject: bug in ftpd. FreeBSD release 4.0 Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----------6F19C18A19F92502" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG ------------6F19C18A19F92502 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello freebsd-questions, FreeBSD ftp daemon have bugs in "selecthost" function, that causes not correct virtual hosting support. I have detected that in FreeBSD release 4.0. 3.x releases have not same bugs. selecthost(su) union sockunion *su; { ... while (hrp != NULL) { for (hi = hrp->hostinfo; hi != NULL; hi = hi->ai_next) { if (memcmp(su, hi->ai_addr, hi->ai_addrlen) == 0) { >>The su union have not compatible format with sockaddr struct. >>Therefore we do not find host which necessary thishost = hrp; break; >> When break cause we break the "FOR" cycle not the "while" >> Actually even if we find necessary hrp structure we do not break >> main "WHILE" cycle ;) } #ifdef INET6 &((struct sockaddr_in *)hi->ai_addr)->sin_addr, sizeof(struct in_addr)) == 0)) { thishost = hrp; break; >> Same problem like described above. } #endif For show that i attach patch. Best regards, isv mailto:isv@false.vmts.ru ------------6F19C18A19F92502 Content-Type: application/octet-stream; name="ftpd.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ftpd.patch" --- ftpd.orig Fri Jun 16 21:04:33 2000 +++ ftpd.c Fri Jun 16 21:04:27 2000 @@ -772,6 +772,7 @@ selecthost(su) union sockunion *su; { + int find=0; struct ftphost *hrp; u_int16_t port; #ifdef INET6 @@ -792,11 +793,12 @@ hrp = thishost = firsthost; /* default */ port = su->su_port; su->su_port = 0; - while (hrp != NULL) { + while (hrp != NULL && !find) { for (hi = hrp->hostinfo; hi != NULL; hi = hi->ai_next) { - if (memcmp(su, hi->ai_addr, hi->ai_addrlen) == 0) { + if (memcmp(&su->su_sin, hi->ai_addr, hi->ai_addrlen) == 0) { thishost = hrp; + find=1; break; } #ifdef INET6 @@ -806,6 +808,7 @@ &((struct sockaddr_in *)hi->ai_addr)->sin_addr, sizeof(struct in_addr)) == 0)) { thishost = hrp; + find=1; break; } #endif ------------6F19C18A19F92502-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message