Donate Share

Bagley: Greylisting for Exim 4

Tracker: Bugs

5 Code review: integer type used to store IPv4 addresses - ID: 2800269
Last Update: Settings changed ( bonebill )

In various places, we store IPv4 addresses packed into an (unsigned)
integer type.

The code was reviewed in the light of the desire to target an x86_64
platform.

The code was originally targetted for the i386 32-bit platform where
'unsigned long' was a 32-bit unsigned integer.

On the version of G++ used, 'unsigned long' turned out to be a 64-bit
unsigned integer. Whilst this will probably not break anything, it calls
into question whether that is the right type to be using.

It turns out that we can use the type 'uint_fast32_t' to tell the compiler
that we want to store at least 32 bits, but that it should use the fastest
convenient representation.

If we use this, we then don't know which type the compiler will choose, so
if we are having these values formatted by 'printf', then we need to cast
them to a known integer type first. We can use 'unsigned long' for this
purpose, as this is unlikely to ever be less than 32 bits.

Also, the function name 'dotted_quad_to_ulong' therefore becomes a
misnomer. The function can be renamed to 'dotted_quad_to_uint'.


William Blunn ( bonebill ) - 2009-06-03 00:01

5

Closed

Fixed

William Blunn

None

None

Public


Comments ( 2 )




Date: 2009-06-03 02:58
Sender: bonebillProject Admin

Fixed in release 0.03


Date: 2009-06-03 01:10
Sender: bonebillProject Admin

Fixed in CVS as of

bagley-main.cxx revision 1.4
bagley-util.cxx revision 1.2
bagley-util.h revision 1.2
db-convert.cxx revision 1.2


Log in to comment.

Attached File

No Files Currently Attached

Changes ( 4 )

Field Old Value Date By
status_id Open 2009-06-03 02:58 bonebill
resolution_id Accepted 2009-06-03 02:58 bonebill
close_date - 2009-06-03 02:58 bonebill
resolution_id None 2009-06-03 00:11 bonebill