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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Fix strftime usage on Win32 when trying to fetch the locale-aware
Date: 2009-01-09 13:41:45
Message-ID: 17487.1231508505@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

mha(at)postgresql(dot)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

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Magnus Hagander 2009-01-09 13:52:05 Re: pgsql: Fix strftime usage on Win32 when trying to fetch the locale-aware
Previous Message Peter Eisentraut 2009-01-09 13:37:18 pgsql: Change chapter titles thus: III.