postgresql/contrib/pgcrypto
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 Loop when necessary in contrib/pgcrypto's pktreader_pull(). 2014-11-11 17:22:15 -05:00
sql Loop when necessary in contrib/pgcrypto's pktreader_pull(). 2014-11-11 17:22:15 -05:00
.gitignore Support "make check" in contrib 2011-04-25 22:27:11 +03:00
Makefile Add functions for dealing with PGP armor header lines to pgcrypto. 2014-10-01 16:03:39 +03:00
blf.c Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
blf.h Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
crypt-blowfish.c pgcrypto: fix memset() calls that might be optimized away 2014-04-17 12:37:53 -04:00
crypt-des.c Replace a bunch more uses of strncpy() with safer coding. 2015-01-24 13:05:42 -05:00
crypt-gensalt.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
crypt-md5.c pgcrypto: fix memset() calls that might be optimized away 2014-04-17 12:37:53 -04:00
fortuna.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
fortuna.h pgindent run for 9.4 2014-05-06 12:12:18 -04:00
imath.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
imath.h pgindent run for 9.4 2014-05-06 12:12:18 -04:00
internal-sha2.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
internal.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
mbuf.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
mbuf.h pgindent run for 9.4 2014-05-06 12:12:18 -04:00
md5.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
md5.h pgindent run for 9.4 2014-05-06 12:12:18 -04:00
openssl.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgcrypto--1.0--1.1.sql Add gen_random_uuid() to contrib/pgcrypto. 2014-01-17 16:52:06 -05:00
pgcrypto--1.1--1.2.sql Add functions for dealing with PGP armor header lines to pgcrypto. 2014-10-01 16:03:39 +03:00
pgcrypto--1.2.sql Fix file-identification comment in contrib/pgcrypto/pgcrypto--1.2.sql. 2014-10-20 10:53:57 -04:00
pgcrypto--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
pgcrypto.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgcrypto.control Add functions for dealing with PGP armor header lines to pgcrypto. 2014-10-01 16:03:39 +03:00
pgcrypto.h pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgp-armor.c Add functions for dealing with PGP armor header lines to pgcrypto. 2014-10-01 16:03:39 +03:00
pgp-cfb.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgp-compress.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgp-decrypt.c Loop when necessary in contrib/pgcrypto's pktreader_pull(). 2014-11-11 17:22:15 -05:00
pgp-encrypt.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgp-info.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgp-mpi-internal.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgp-mpi-openssl.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgp-mpi.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgp-pgsql.c Docs: fix incorrect spelling of contrib/pgcrypto option. 2014-11-03 11:11:34 -05:00
pgp-pubdec.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgp-pubenc.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgp-pubkey.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgp-s2k.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgp.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgp.h Add functions for dealing with PGP armor header lines to pgcrypto. 2014-10-01 16:03:39 +03:00
px-crypt.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
px-crypt.h pgindent run for 9.4 2014-05-06 12:12:18 -04:00
px-hmac.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
px.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
px.h pgindent run for 9.4 2014-05-06 12:12:18 -04:00
random.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
rijndael.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
rijndael.h pgindent run for 9.4 2014-05-06 12:12:18 -04:00
rijndael.tbl Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
sha1.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
sha1.h pgindent run for 9.4 2014-05-06 12:12:18 -04:00
sha2.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
sha2.h pgindent run for 9.4 2014-05-06 12:12:18 -04:00