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

SourceForge.net noreply at sourceforge.net
Wed Feb 6 18:31:37 UTC 2008


Patches item #1888101, was opened at 2008-02-06 19:29
Message generated for change (Settings changed) made by gcoriasco
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=743022&aid=1888101&group_id=139143

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: modules
Group: ver 1.3.x
Status: Open
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Giovanni Coriasco (gcoriasco)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bug in hash.c of permission module

Initial Comment:
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 respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=743022&aid=1888101&group_id=139143



More information about the Devel mailing list