postgresql/contrib/xml2
Tom Lane 586dd5d6a5 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:42 -05:00
..
expected Prevent access to external files/URLs via contrib/xml2's xslt_process(). 2012-08-14 18:31:18 -04:00
sql Prevent access to external files/URLs via contrib/xml2's xslt_process(). 2012-08-14 18:31:18 -04:00
.gitignore Support "make check" in contrib 2011-04-25 22:27:11 +03:00
Makefile Add file version information to most installed Windows binaries. 2014-07-14 14:07:52 -04:00
xml2--1.0.sql Throw a useful error message if an extension script file is fed to psql. 2011-10-12 15:45:03 -04:00
xml2--unpackaged--1.0.sql Fix typos in some error messages thrown by extension scripts when fed to psql. 2014-08-25 18:30:37 +02:00
xml2.control Fix upgrade of contrib/xml2 from 9.0. 2011-02-17 18:11:28 -05:00
xpath.c Replace a bunch more uses of strncpy() with safer coding. 2015-01-24 13:05:42 -05:00
xslt_proc.c Free libxml2/libxslt resources in a safer order. 2014-11-27 11:13:29 -05:00