Prevent using strncpy with src == dest in TupleDescInitEntry.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 29 Oct 2013 00:49:32 +0000 (20:49 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 29 Oct 2013 00:49:32 +0000 (20:49 -0400)
commita37f94ae4106634babe53a30a0cfc80380c12431
treed6f40fb891628db7fee94473457f670a710787bc
parent9060cb96805e0d3cfe74c0919feb5e2ce1034ffc
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.
src/backend/access/common/tupdesc.c