Problem in client_find() in CVS head
I get errors "Ignoring request from unknown client ..." when using the CVS head version. I think there is a problem in the IPv4 addresses comparison in client_find(). The following patch solved the problem for me, but perhaps there is a better solution. If I get approval, I can commit it to the CVS. Index: src/main/client.c =================================================================== RCS file: /source/radiusd/src/main/client.c,v retrieving revision 1.35 diff -u -r1.35 client.c --- src/main/client.c 12 May 2005 22:22:48 -0000 1.35 +++ src/main/client.c 30 Jun 2005 16:04:34 -0000 @@ -271,7 +271,8 @@ switch (ipaddr->af) { case AF_INET: if (cl->prefix) { - if ((htonl(ipaddr->ipaddr.ip4addr.s_addr) & (~0 << cl->prefix)) == (htonl(cl->ipaddr.ipaddr.ip4addr.s_addr) & (~0 << cl->prefix))) { + uint32_t mask = htonl(~((1 << (32 - cl->prefix)) - 1)); + if ((ipaddr->ipaddr.ip4addr.s_addr & mask) == (cl->ipaddr.ipaddr.ip4addr.s_addr & mask)) { match = cl; } else break; -- Nicolas Baradakis
Nicolas Baradakis <nbk@sitadelle.com> wrote:
The following patch solved the problem for me, but perhaps there is a better solution. If I get approval, I can commit it to the CVS.
It looks fine to me. I think the problem in the original version was the ~0 stuff, which wasn't cast to uint32_t. It works for me, so I didn't see it as a problem. But the new code is clearer, and most likely more portable. Alan DeKok.
Alan DeKok wrote:
The following patch solved the problem for me, but perhaps there is a better solution. If I get approval, I can commit it to the CVS.
It looks fine to me.
I think the problem in the original version was the ~0 stuff, which wasn't cast to uint32_t. It works for me, so I didn't see it as a problem. But the new code is clearer, and most likely more portable.
Thankyou for the favorable comment. I added the patch in the CVS a few minutes ago. -- Nicolas Baradakis
participants (2)
-
Alan DeKok -
Nicolas Baradakis