postgresql/src
Tom Lane d51d4ff311 Replace a bunch more uses of strncpy() with safer coding.
strncpy() has a well-deserved reputation for being unsafe, so make an
effort to get rid of nearly all occurrences in HEAD.

A large fraction of the remaining uses were passing length less than or
equal to the known strlen() of the source, in which case no null-padding
can occur and the behavior is equivalent to memcpy(), though doubtless
slower and certainly harder to reason about.  So just use memcpy() in
these cases.

In other cases, use either StrNCpy() or strlcpy() as appropriate (depending
on whether padding to the full length of the destination buffer seems
useful).

I left a few strncpy() calls alone in the src/timezone/ code, to keep it
in sync with upstream (the IANA tzcode distribution).  There are also a
few such calls in ecpg that could possibly do with more analysis.

AFAICT, none of these changes are more than cosmetic, except for the four
occurrences in fe-secure-openssl.c, which are in fact buggy: an overlength
source leads to a non-null-terminated destination buffer and ensuing
misbehavior.  These don't seem like security issues, first because no stack
clobber is possible and second because if your values of sslcert etc are
coming from untrusted sources then you've got problems way worse than this.
Still, it's undesirable to have unpredictable behavior for overlength
inputs, so back-patch those four changes to all active branches.
2015-01-24 13:05:45 -05:00
..
backend Adjust "pgstat wait timeout" message to be a translatable LOG message. 2015-01-19 23:01:36 -05:00
bin Fix use of already freed memory when dumping a database's security label. 2015-01-18 16:16:22 +01:00
common Fix libpq's behavior when /etc/passwd isn't readable. 2015-01-11 12:35:47 -05:00
include Improve performance of EXPLAIN with large range tables. 2015-01-15 13:18:16 -05:00
interfaces Replace a bunch more uses of strncpy() with safer coding. 2015-01-24 13:05:45 -05:00
makefiles Remove USE_VPATH make variable from PGXS 2014-12-04 08:45:48 -05:00
pl Fix some functions that were declared static then defined not-static. 2015-01-12 16:08:46 -05:00
port Another attempt at fixing Windows Norwegian locale. 2015-01-16 13:10:06 +02:00
template Revert to using --enable-auto-import in Cygwin builds. 2014-02-16 15:14:04 -05:00
test In pg_regress, remove the temporary installation upon successful exit. 2015-01-19 23:44:22 -05:00
timezone Add CST (China Standard Time) to our lists of timezone abbreviations. 2014-12-24 16:35:34 -05:00
tools Add pg_string_endswith as the start of a string helper library in src/common. 2015-01-03 20:54:13 +01:00
tutorial pgindent run for 9.4 2014-05-06 12:12:18 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
bcc32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Create libpgcommon, and move pg_malloc et al to it 2013-02-12 11:21:05 -03:00
Makefile.global.in Fix installcheck case for tap tests 2014-12-24 10:32:02 -05:00
Makefile.shlib MinGW: Include .dll extension in .def file LIBRARY commands. 2014-10-27 19:59:52 -04:00
nls-global.mk Setup error context callback for transaction lock waits 2014-03-19 15:10:36 -03:00
win32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00