[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#5436) htons() expects an unsigned short



Thanks.  Fixed os-ip.c in CVS HEAD (but see below).

rein@basefarm.no writes:
> libraries/libldap/os-ip.c casts the argument to htons() to a short, it
> should be an explicit unsigned short.  This causes the use of high
> port numbers to fail on systems where shorts are signed by default.

short is signed by definition.

Do you have a test case?  As far as I can tell it broke if the caller
had the same error: storing a port number in a short, and passing that
short to ldap_init() & co.  And it broke on systems with 16-bit int, if
there are such system around where OpenLDAP compiles in the first place.

If we care about systems with 16-bit int, the proper fix is to also make
LDAPURLDesc.lud_port and various 'port' function parameters unsigned.  I
have no idea if there is such a system which can even compile OpenLDAP
though.

-- 
Hallvard