Re: pgsql: Fix strftime usage on Win32 when trying to fetch the locale-aware - Mailing list pgsql-committers

From Tom Lane
Subject Re: pgsql: Fix strftime usage on Win32 when trying to fetch the locale-aware
Date
Msg-id 17487.1231508505@sss.pgh.pa.us
Whole thread Raw
In response to pgsql: Fix strftime usage on Win32 when trying to fetch the locale-aware  (mha@postgresql.org (Magnus Hagander))
Responses Re: pgsql: Fix strftime usage on Win32 when trying to fetch the locale-aware  (Magnus Hagander <magnus@hagander.net>)
List pgsql-committers
mha@postgresql.org (Magnus Hagander) writes:
> Fix strftime usage on Win32 when trying to fetch the locale-aware
> parts of a time string so it properly handles different encodings.

Hmm, this patch has

+     wchar_t    wbuf[MAX_L10N_DATA];
+
+     len = wcsftime(wbuf, sizeof(wbuf), format, tm);

The Single Unix Spec's definition of wcsftime says that the above
risks a buffer overrun, and the correct second argument would be
MAX_L10N_DATA.  Now I realize that SUS is a poor guide for
Windows-specific code, but are you sure this is right?

Also, I believe we've deprecated StrNCpy; use strlcpy if possible.

            regards, tom lane

pgsql-committers by date:

Previous
From: petere@postgresql.org (Peter Eisentraut)
Date:
Subject: pgsql: Change chapter titles thus: III.
Next
From: Magnus Hagander
Date:
Subject: Re: pgsql: Fix strftime usage on Win32 when trying to fetch the locale-aware