two warning on build samba-3.0.15pre2
derrell at samba.org
derrell at samba.org
Thu Apr 21 14:05:49 GMT 2005
Дейтер Александр Валериевич <tiamat at komi.mts.ru> writes:
> derrell at samba.org wrote :
>
>>> size_t ret = iconv((iconv_t)cd,
>>>- CONST_DISCARD(char **, inbuf), inbytesleft,
>>>+ inbuf, inbytesleft,
>> The local variable "inbuf" here is of type (const char **).
>> The second parameter to iconv(), as specified in my Linux documentation and in
>> <iconv.h>, is type (char **).
>> What OS are you running, and how is iconv() declared in <iconv.h>? This
>> sounds like a difference in standard function declaration (sigh).
>
> FreeBSD 5.3 + libiconv-1.9.2 (from http://www.gnu.org/software/libiconv)
>
> /usr/local/include/iconv.h:
> extern size_t iconv (iconv_t cd, const char* * inbuf, size_t
> *inbytesleft, char* * outbuf, size_t *outbytesleft);
Ugh. So we need a configure check to determine the type of parameters just to
avoid compiler warnings? That's nasty. All right, let me think about it.
> /usr/include/sys/time.h:
> #include <sys/_timeval.h>
>
> /usr/include/sys/_timeval.h:
> struct timeval {
> long tv_sec; /* seconds (XXX should be
> time_t) */
> suseconds_t tv_usec; /* and microseconds */
> };
>
Yeah, same thing here. (And as the comment says, it *should* be time_t, so
why didn't they just fix it?????)
> source/utils/status.c also contain code:
> asctime(LocalTime((time_t *)&e->time.tv_sec)));
Yes, but this is really broken. Casting the address of a variable without
really knowing what type it is can cause the wrong data to be used by the
called function. In severe cases (where the passed pointer is dereferenced
and written to), memory other than the field intended to be modified can
become corrupted.
These time function issues are easy to fix, though; we just need to assign the
value to a local (time_t) variable and pass the address of that instead. It's
the differences in prototypes that bug me. Sigh.
Thanks for the report!
Derrell
More information about the samba-technical
mailing list