StrNCpy

Поиск
Список
Период
Сортировка
От Maurice Gittens
Тема StrNCpy
Дата
Msg-id 006201bd5c85$145d3360$fcf3b2c2@caleb..gits.nl
обсуждение исходный текст
Ответы Re: [HACKERS] StrNCpy  (Bruce Momjian <maillist@candle.pha.pa.us>)
Список pgsql-hackers
Hi,

While debugging yet another overrun I came across the StrNCpy macro.
A quick grep of the source tells me that usage of the StrNCpy macro is
seemingly inconsistent.

Usage 1:
strptr = palloc(len);    // done is a diffrent context
ptr = palloc(len + 1);
StrNCpy(ptr, strptr, len + 1);

Usage 2:
NameData name;
StrNCpy(name.data, ptr2name, NAMEDATALEN);

The StrNCpy macro zero terminates the destination buffer.

Usage 1 is gives a read=buffer overrun (which I agree is not the most
serious of bugs
if you system doesn't dump core on it).
Usage 2 makes gives the name a maximum of 31 instead of 32 characters.

Is the maximun name length supposted to be 31 or 32 characters?

With regards from Maurice.


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

Предыдущее
От: Goran Thyni
Дата:
Сообщение: free-text searching
Следующее
От: "Boersenspielteam"
Дата:
Сообщение: Re: [HACKERS] Reminder: Indices are not used