[Zlib-devel] zlib version 1.2.3.8 available for testing

Philip Lowman philip at yhbt.com
Mon Feb 15 21:46:31 EST 2010


On Mon, Feb 15, 2010 at 2:16 AM, Mark Adler <madler at alumni.caltech.edu> wrote:
> On Feb 14, 2010, at 10:52 PM, Philip Lowman wrote:
>> Since the code is calling snprintf() explicitly that's why it's failing.
>
> Philip,
>
> gzwrite.c will not call or even try to link snprintf() if WIN32 or _WIN32 or __WIN32__ is defined.  It uses vsnprintf() in that case.
>
> The logic in zconf.h is that if _WIN32 or __WIN32__ are defined, then WIN32 is defined if it isn't already.  If WIN32 is defined, then STDC is defined if it isn't already.  In gzwrite.c, if STDC is defined, then the gzprintf() function will use vsnprintf(), unless NO_vsnprintf is defined, in which case it uses vsprintf().  Either way, it doesn't use snprintf().
>
> Your patch implies that WIN32 is in fact defined.  So can you tell what's going on here?

There's nothing wrong with gzwrite.c, it compiles fine.  The issue is
in gzlib.c.

> Whatever is going on, the proper fix would be to use vsnprintf(), not _snprintf().

I've submitted the patch to use _snprintf and as another user pointed
out the #define can be added to just the source file if desired
(wrapped in #ifdef _MSC_VER).  I don't know how to implement the code
with vsnprintf and varargs otherwise I would submit a proper fix
(assuming that adding varags doesn't change ABI compatibility... i
really have no idea!).  I think I'll just leave this change to someone
who knows what they're doing (i.e. not me). :)

-- 
Philip Lowman




More information about the Zlib-devel mailing list