Re:Avoid an odd undefined behavior with memcmp (src/bin/pg_rewind/pg_rewind.c)

Поиск
Список
Период
Сортировка
От Long Song
Тема Re:Avoid an odd undefined behavior with memcmp (src/bin/pg_rewind/pg_rewind.c)
Дата
Msg-id 5b47b4b4.1a13.18fc728c5a0.Coremail.songlong88@126.com
обсуждение исходный текст
Ответ на Avoid an odd undefined behavior with memcmp (src/bin/pg_rewind/pg_rewind.c)  (Ranier Vilela <ranier.vf@gmail.com>)
Ответы Re: Avoid an odd undefined behavior with memcmp (src/bin/pg_rewind/pg_rewind.c)
Список pgsql-hackers
Hi Ranier,



> IMO, I think that pg_rewind can have a security issue,
> if two files are exactly the same, they are considered different.
> Because use of structs with padding values is unspecified.
Logically you are right. But I don't understand what scenario
would require memcmp to compare ControlFileData.
In general, we read ControlFileData from a pg_control file
and then use members of ControlFileData directly.
So the two ControlFileData are not directly compared by byte.

> Fix by explicitly initializing with memset to avoid this.
And, even if there are scenarios that use memcmp comparisons,
your modifications are not complete.
There are three calls to the digestControlFile in the main()
of pg_rewind.c, and as your said(if right), these should do
memory initialization every time.





--
Best Regards,

Long

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

Предыдущее
От: Noah Misch
Дата:
Сообщение: Re: Remove last traces of HPPA support
Следующее
От: Peter Smith
Дата:
Сообщение: Re: Improving the latch handling between logical replication launcher and worker processes.