Problem in client_find() in CVS head

classic Classic list List threaded Threaded
3 messages Options
| Threaded
Open this post in threaded view
|

Problem in client_find() in CVS head

Nicolas Baradakis
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

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
| Threaded
Open this post in threaded view
|

Re: Problem in client_find() in CVS head

Alan DeKok
Nicolas Baradakis <[hidden email]> 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.

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
| Threaded
Open this post in threaded view
|

Re: Problem in client_find() in CVS head

Nicolas Baradakis
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

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html