Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

Поиск
Список
Период
Сортировка
От Richard Guo
Тема Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)
Дата
Msg-id CAMbWs4-f4D425C73p0WPBYb2qpiGZyJGvivxS15rEz_igR8vMQ@mail.gmail.com
обсуждение исходный текст
Ответ на Avoid incomplete copy string (src/backend/access/transam/xlog.c)  (Ranier Vilela <ranier.vf@gmail.com>)
Ответы Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)
Список pgsql-hackers
On Mon, Jun 24, 2024 at 7:51 AM Ranier Vilela <ranier.vf@gmail.com> wrote:
> In src/include/access/xlogbackup.h, the field *name*
> has one byte extra to store null-termination.
>
> But, in the function *do_pg_backup_start*,
> I think that is a mistake in the line (8736):
>
> memcpy(state->name, backupidstr, strlen(backupidstr));
>
> memcpy with strlen does not copy the whole string.
> strlen returns the exact length of the string, without
> the null-termination.

I noticed that the two callers of do_pg_backup_start both allocate
BackupState with palloc0.  Can we rely on this to ensure that the
BackupState.name is initialized with null-termination?

Thanks
Richard



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

Предыдущее
От:
Дата:
Сообщение: RE: Improve EXPLAIN output for multicolumn B-Tree Index
Следующее
От: Yugo NAGATA
Дата:
Сообщение: Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)