Date: Sat, 17 Jun 2000 09:38:00 +1100 From: isv <isv@false.vmts.ru> To: freebsd-questions@FreeBSD.ORG Subject: bug in ftpd. FreeBSD release 4.0 Message-ID: <17401.000617@false.vmts.ru>
index | next in thread | raw e-mail
[-- Attachment #1 --]
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
[-- Attachment #2 --]
--- 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
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?17401.000617>
