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

(ITS#5105) 64 bit Windows portability errors in liblber



Full_Name: Alexey Melnikov
Version: 2.3.28
OS: Windows XP
URL: ftp://ftp.openldap.org/incoming/alexey-melnikov-070824.diff
Submission from: (NULL) (62.3.217.250)


Visual C 8.0 reports warnings when building liblber with /Wp64 (64 bit Windows
portability warnings). The warnings are actually bugs on Windows 64:

bprint.c(269) : warning C4311: 'type cast' : pointer truncation from 'char *' to
'long'
bprint.c(270) : warning C4311: 'type cast' : pointer truncation from 'char *' to
'long'
bprint.c(271) : warning C4311: 'type cast' : pointer truncation from 'char *' to
'long'
bprint.c(308) : warning C4311: 'type cast' : pointer truncation from 'char *' to
'long'
bprint.c(309) : warning C4311: 'type cast' : pointer truncation from 'char *' to
'long'
decode.c(376) : warning C4311: 'type cast' : pointer truncation from 'BerVarray'
to 'long'
decode.c(377) : warning C4312: 'type cast' : conversion from 'unsigned long' to
'berval *' of greater size
decode.c(409) : warning C4311: 'type cast' : pointer truncation from 'BerVarray'
to 'long'
decode.c(409) : warning C4312: 'type cast' : conversion from 'unsigned long' to
'BerVarray' of greater size

Warnings in bprint.c are caused by use of %X which is incorrect on Windows 64.
Portable %p should be used instead.
Problems in decode.c are caused by typecasting a pointer to a long.
Unfortunately on Windows 64 a pointer is 64 bits, while "long" is still 32bits,
which is obviously problematic. The fix is to use typecase to "char *" instead,
as pointer arithmetics will work for it.

I've uploaded the patch as
<ftp://ftp.openldap.org/incoming/alexey-melnikov-070824.diff>