Re: Out-of-bounds write and incorrect detection of trigger file in pg_standby

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: Out-of-bounds write and incorrect detection of trigger file in pg_standby
Дата
Msg-id CAB7nPqSB6eY_Lcwyou=8Gnc9Y65oSfOazuKG5siDozQSUqxVAQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Out-of-bounds write and incorrect detection of trigger file in pg_standby  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: Out-of-bounds write and incorrect detection of trigger file in pg_standby  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
On Thu, Jan 15, 2015 at 7:13 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> Instead of doing this:
>
>     if (len < sizeof(buf))
>         buf[len] = '\0';
>
> ...I would suggest making the size of the buffer one greater than the
> size of the read(), and then always nul-terminating the buffer.  It
> seems to me that would make the code easier to reason about.
How about the attached then? This way we still detect the same way any
invalid values:
-       if ((len = read(fd, buf, sizeof(buf))) < 0)
+       if ((len = read(fd, buf, sizeof(buf) - 1)) < 0)
Regards,
--
Michael

Вложения

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

Предыдущее
От: Amit Langote
Дата:
Сообщение: Partitioning: issues/ideas (Was: Re: On partitioning)
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Safe memory allocation functions