Re: strncpy is not a safe version of strcpy

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: strncpy is not a safe version of strcpy
Дата
Msg-id 1384530979.22076.YahooMailNeo@web162901.mail.bf1.yahoo.com
обсуждение исходный текст
Ответ на Re: strncpy is not a safe version of strcpy  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> Kevin Grittner escribió:

>> That argument would be more persuasive if I could find any current
>> usage of the namecpy() function anywhere in the source code.
>
> Well, its cousin namestrcpy is used in a lot of places.  That one uses a
> regular C string as source; namecpy uses a Name as source, so they are
> slightly different but the coding is pretty much the same.

Fair enough.

> There is a difference in using the macro StrNCpy instead of the strncpy
> library function directly.  ISTM this makes sense because Name is known
> to be zero-terminated at NAMEDATALEN, which a random C string is not.

Is the capital T in the second #undef in this pg_locale.c code intended?:

#ifdef WIN32
/*
 * This Windows file defines StrNCpy. We don't need it here, so we undefine
 * it to keep the compiler quiet, and undefine it again after the file is
 * included, so we don't accidentally use theirs.
 */
#undef StrNCpy
#include <shlwapi.h>
#ifdef StrNCpy
#undef STrNCpy
#endif
#endif

--
Kevin GrittnerEDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: SSL renegotiation
Следующее
От: Tom Lane
Дата:
Сообщение: Re: SSL renegotiation