pgsql: Prevent using strncpy with src == dest in TupleDescInitEntry.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Prevent using strncpy with src == dest in TupleDescInitEntry.
Дата
Msg-id E1VaxVb-0003cL-7P@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Prevent using strncpy with src == dest in TupleDescInitEntry.

The C and POSIX standards state that strncpy's behavior is undefined when
source and destination areas overlap.  While it remains dubious whether any
implementations really misbehave when the pointers are exactly equal, some
platforms are now starting to force the issue by complaining when an
undefined call occurs.  (In particular OS X 10.9 has been seen to dump core
here, though the exact set of circumstances needed to trigger that remain
elusive.  Similar behavior can be expected to be optional on Linux and
other platforms in the near future.)  So tweak the code to explicitly do
nothing when nothing need be done.

Back-patch to all active branches.  In HEAD, this also lets us get rid of
an exception in valgrind.supp.

Per discussion of a report from Matthias Schmitt.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/9a9473f3cce1a21c25d6cc7569710e832d2b180b

Modified Files
--------------
src/backend/access/common/tupdesc.c |   14 ++++++++++----
src/tools/valgrind.supp             |   16 ----------------
2 files changed, 10 insertions(+), 20 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Prevent using strncpy with src == dest in TupleDescInitEntry.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Prevent using strncpy with src == dest in TupleDescInitEntry.