postgresql/src/include
Tom Lane 5c784d96ae Fix off-by-one loop count in MapArrayTypeName, and get rid of static array.
MapArrayTypeName would copy up to NAMEDATALEN-1 bytes of the base type
name, which of course is wrong: after prepending '_' there is only room for
NAMEDATALEN-2 bytes.  Aside from being the wrong result, this case would
lead to overrunning the statically allocated work buffer.  This would be a
security bug if the function were ever used outside bootstrap mode, but it
isn't, at least not in any currently supported branches.

Aside from fixing the off-by-one loop logic, this patch gets rid of the
static work buffer by having MapArrayTypeName pstrdup its result; the sole
caller was already doing that, so this just requires moving the pstrdup
call.  This saves a few bytes but mainly it makes the API a lot cleaner.

Back-patch on the off chance that there is some third-party code using
MapArrayTypeName with less-secure input.  Pushing pstrdup into the function
should not cause any serious problems for such hypothetical code; at worst
there might be a short term memory leak.

Per Coverity scanning.
2014-12-16 15:35:46 -05:00
..
access Flush unlogged table's buffers when copying or moving databases. 2014-10-20 23:47:45 +02:00
bootstrap Fix off-by-one loop count in MapArrayTypeName, and get rid of static array. 2014-12-16 15:35:46 -05:00
catalog Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
commands Test IsInTransactionChain, not IsTransactionBlock, in vac_update_relstats. 2014-10-30 13:03:34 -04:00
executor Avoid leaking memory while evaluating arguments for a table function. 2014-06-19 22:13:54 -04:00
foreign pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
lib Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
libpq Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
mb Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
nodes Avoid leaking memory while evaluating arguments for a table function. 2014-06-19 22:13:54 -04:00
optimizer Fix generation of MergeAppend plans for optimized min/max on expressions. 2013-11-07 13:13:47 -05:00
parser Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
port Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
portability Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
postmaster Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
regex Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
replication Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
rewrite Avoid getting more than AccessShareLock when deparsing a query. 2014-03-06 19:31:16 -05:00
snowball Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
storage Backport "Expose fsync_fname as a public API". 2014-11-15 01:22:32 +01:00
tcop Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
tsearch Predict integer overflow to avoid buffer overruns. 2014-02-17 09:33:37 -05:00
utils Support timezone abbreviations that sometimes change. 2014-10-16 15:22:23 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
c.h Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
fmgr.h Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
funcapi.h Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
getaddrinfo.h Fix assorted issues in client host name lookup. 2014-04-02 17:11:34 -04:00
getopt_long.h Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
Makefile Fix server header file installation with vpath builds 2011-11-10 20:54:50 +02:00
miscadmin.h Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
pg_config.h.in Add mkdtemp() to libpgport. 2014-06-14 09:41:18 -04:00
pg_config.h.win32 Stamp 9.1.14. 2014-07-21 15:14:13 -04:00
pg_config_manual.h Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
pg_trace.h Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
pgstat.h Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
pgtime.h Support timezone abbreviations that sometimes change. 2014-10-16 15:22:23 -04:00
port.h Declare mkdtemp() only if we're providing it. 2014-10-17 22:55:33 -04:00
postgres.h Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
postgres_ext.h Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
postgres_fe.h Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
rusagestub.h Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
windowapi.h Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00