[OpenSER-Devel] Bug in hash.c of permission module

Giovanni Coriasco giovanni.coriasco at csp.it
Tue Jan 29 16:59:06 UTC 2008


Hi,

I'm running an Openser version 1.3.0 on a Linux machine.

I think I found a bug in the "permissions" module. The allow_address() 
and allow_source_address() operate properly only with /0, /8, /16, /24, 
/32 netmasks so far.

The problem is in the fact that a shift operator (<<) is used with 
addresses in network byte order.

In fact, an IP address A.B.C.D has the following form in network byte order:

ddddddddccccccccbbbbbbbbaaaaaaaa

where the aaa are the bits (in LITTLE endian format) of the byte A.

The problem with the shift operation is that the byte order is BIG 
endian, BUT each byte has a LITTLE endian order for its bits.

Instead, in host byte order, both bits and bytes have little endian 
format and you just have to invert the shift operation (<< to >> and >> 
to <<).

The patch I wrote converts the address to host byte order before 
shifting and convert back the result to network byte order.

You can find my patch attached to this email: I hope you will find it 
useful.

Bye

Giovanni


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hash.c.patch
Url: http://lists.openser.org/pipermail/devel/attachments/20080129/d6f35f34/attachment-0001.txt 


More information about the Devel mailing list