Re: pg_rewind copies

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: pg_rewind copies
Дата
Msg-id 97e6edb1-0f9a-685a-c860-0d886d8f94ba@enterprisedb.com
обсуждение исходный текст
Ответ на Re: pg_rewind copies  (Daniel Gustafsson <daniel@yesql.se>)
Ответы Re: pg_rewind copies  (Daniel Gustafsson <daniel@yesql.se>)
Список pgsql-hackers
On 01.04.22 11:00, Daniel Gustafsson wrote:
> One small comment on the patch:
> 
> +   snprintf(srcpath, sizeof(srcpath), "%s/%s", datadir, path);
> 
> This should IMO check the returnvalue of snprintf to ensure it wasn't
> truncated.  While the risk is exceedingly small, a truncated filename might
> match another existing filename and the error not getting caught.  There is
> another instance just like this one in open_target_file() to which I think we
> should apply the same belts-and-suspenders treatment.  I've fixed this in the
> attached version which also have had a pg_indent run on top of a fresh rebase.

We use snprintf() like that countless times, and approximately none of 
them check for overflow.  So while you are right, this might not be the 
place to start a new policy.

If you don't like this approach, use psprintf() perhaps.



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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: [PATCH v2] use has_privs_for_role for predefined roles
Следующее
От: Thomas Munro
Дата:
Сообщение: Re: shared-memory based stats collector - v68