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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: pgsql: Fix strftime usage on Win32 when trying to fetch the locale-aware
Дата
Msg-id 19567.1231509351@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: pgsql: Fix strftime usage on Win32 when trying to fetch the locale-aware  (Magnus Hagander <magnus@hagander.net>)
Ответы Re: pgsql: Fix strftime usage on Win32 when trying to fetch the locale-aware  (Magnus Hagander <magnus@hagander.net>)
Список pgsql-committers
Magnus Hagander <magnus@hagander.net> writes:
> Tom Lane wrote:
>> 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?

> Now that I read it again, I think you're right. What MS says is:
> "If the total number of characters, including the terminating null, is
> more than maxsize, both strftime and wcsftime return 0 and the contents
> of strDest are indeterminate."

> The important difference being "character" vs "bytes", right?

SUS phrases it as

"If the total number of resulting wide-character codes including the
terminating null wide-character code is no more than maxsize, wcsftime()
returns the number of wide-character codes placed into the array pointed
to by wcs, not including the terminating null wide-character
code. Otherwise 0 is returned and the contents of the array are
indeterminate."

so it's very clear that maxsize is counted in wchars.

Perhaps someone could experiment to double-check what Windows does.

            regards, tom lane

В списке pgsql-committers по дате отправления:

Предыдущее
От: Magnus Hagander
Дата:
Сообщение: Re: pgsql: Fix strftime usage on Win32 when trying to fetch the locale-aware
Следующее
От: Magnus Hagander
Дата:
Сообщение: Re: pgsql: Fix strftime usage on Win32 when trying to fetch the locale-aware