postgresql/src/backend/access
Tom Lane 54386f3578 Remove triggerable Assert in hashname().
hashname() asserted that the key string it is given is shorter than
NAMEDATALEN.  That should surely always be true if the input is in fact a
regular value of type "name".  However, for reasons of coding convenience,
we allow plain old C strings to be treated as "name" values in many places.
Some SQL functions accept arbitrary "text" inputs, convert them to C
strings, and pass them otherwise-untransformed to syscache lookups for name
columns, allowing an overlength input value to trigger hashname's Assert.

This would be a DOS problem, except that it only happens in assert-enabled
builds which aren't recommended for production.  In a production build,
you'll just get a name lookup error, since regardless of the hash value
computed by hashname, the later equality comparison checks can't match.
Likewise, if the catalog lookup is done by seqscan or indexscan searches,
there will just be a lookup error, since the name comparison functions
don't contain any similar length checks, and will see an overlength input
as unequal to any stored entry.

After discussion we concluded that we should simply remove this Assert.
It's inessential to hashname's own functionality, and having such an
assertion in only some paths for name lookup is more of a foot-gun than
a useful check.  There may or may not be a case for the affected callers
to do something other than let the name lookup fail, but we'll consider
that separately; in any case we probably don't want to change such
behavior in the back branches.

Per report from Tushar Ahuja.  Back-patch to all supported branches.

Report: https://postgr.es/m/7d0809ee-6f25-c9d6-8e74-5b2967830d49@enterprisedb.com
Discussion: https://postgr.es/m/17691.1482523168@sss.pgh.pa.us
2016-12-26 14:58:02 -05:00
..
brin Rewrite PageIndexDeleteNoCompact into a form that only deletes 1 tuple. 2016-09-09 19:00:59 -04:00
common Implement table partitioning. 2016-12-07 13:17:55 -05:00
gin Replace the built-in GIN array opclasses with a single polymorphic opclass. 2016-09-26 14:52:44 -04:00
gist Fix outdated comments, GIST search queue is not an RBTree anymore. 2016-09-20 11:38:25 +03:00
hash Remove triggerable Assert in hashname(). 2016-12-26 14:58:02 -05:00
heap Skip checkpoints, archiving on idle systems. 2016-12-22 11:31:50 -08:00
index Add SQL-accessible functions for inspecting index AM properties. 2016-08-13 18:31:14 -04:00
nbtree Remove should_free arguments to tuplesort routines. 2016-12-12 15:57:35 -05:00
rmgrdesc Fix incorrect output from gin_desc(). 2016-12-05 20:29:41 +09:00
spgist Log the creation of an init fork unconditionally. 2016-12-08 14:12:08 -05:00
tablesample Update copyright for 2016 2016-01-02 13:33:40 -05:00
transam Skip checkpoints, archiving on idle systems. 2016-12-22 11:31:50 -08:00
Makefile TABLESAMPLE, SQL Standard and extensible 2015-05-15 14:37:10 -04:00