postgresql/src/backend
Tom Lane cc4f6b7786 Clean up assorted misuses of snprintf()'s result value.
Fix a small number of places that were testing the result of snprintf()
but doing so incorrectly.  The right test for buffer overrun, per C99,
is "result >= bufsize" not "result > bufsize".  Some places were also
checking for failure with "result == -1", but the standard only says
that a negative value is delivered on failure.

(Note that this only makes these places correct if snprintf() delivers
C99-compliant results.  But at least now these places are consistent
with all the other places where we assume that.)

Also, make psql_start_test() and isolation_start_test() check for
buffer overrun while constructing their shell commands.  There seems
like a higher risk of overrun, with more severe consequences, here
than there is for the individual file paths that are made elsewhere
in the same functions, so this seemed like a worthwhile change.

Also fix guc.c's do_serialize() to initialize errno = 0 before
calling vsnprintf.  In principle, this should be unnecessary because
vsnprintf should have set errno if it returns a failure indication ...
but the other two places this coding pattern is cribbed from don't
assume that, so let's be consistent.

These errors are all very old, so back-patch as appropriate.  I think
that only the shell command overrun cases are even theoretically
reachable in practice, but there's not much point in erroneous error
checks.

Discussion: https://postgr.es/m/17245.1534289329@sss.pgh.pa.us
2018-08-15 16:29:31 -04:00
..
access Make autovacuum more aggressive to remove orphaned temp tables 2018-08-13 11:49:04 +02:00
bootstrap Use a ResourceOwner to track buffer pins in all cases. 2018-07-18 12:15:16 -04:00
catalog Make autovacuum more aggressive to remove orphaned temp tables 2018-08-13 11:49:04 +02:00
commands Remove obsolete comment 2018-08-13 21:07:31 +02:00
executor Adjust comment atop ExecShutdownNode. 2018-08-13 10:04:39 +05:30
foreign Remove bogus "extern" annotations on function definitions. 2018-02-19 12:07:44 -05:00
jit LLVMJIT: Check for 'noinline' attribute in recursively inlined functions. 2018-07-25 16:23:59 -07:00
lib doc: Update redirecting links 2018-07-16 10:48:05 +02:00
libpq Remove support for tls-unique channel binding. 2018-08-05 13:44:21 +03:00
main Update copyright for 2018 2018-01-02 23:30:12 -05:00
nodes Fix run-time partition pruning for appends with multiple source rels. 2018-08-01 19:42:52 -04:00
optimizer Fix wrong order of operations in inheritance_planner. 2018-08-11 15:53:20 -04:00
parser Fix INSERT ON CONFLICT UPDATE through a view that isn't just SELECT *. 2018-08-04 19:38:58 -04:00
partitioning Remove bogus Assert in make_partitionedrel_pruneinfo(). 2018-08-08 20:02:32 -04:00
po Translation updates 2018-06-25 12:37:18 +02:00
port Remove obsolete netbsd dynloader code 2018-08-13 23:21:01 +02:00
postmaster Clean up assorted misuses of snprintf()'s result value. 2018-08-15 16:29:31 -04:00
regex Clean up warnings from -Wimplicit-fallthrough. 2018-05-01 19:35:08 -04:00
replication Don't run atexit callbacks in quickdie signal handlers. 2018-08-08 19:10:32 +03:00
rewrite Fix INSERT ON CONFLICT UPDATE through a view that isn't just SELECT *. 2018-08-04 19:38:58 -04:00
snowball Avoid unnecessary use of pg_strcasecmp for already-downcased identifiers. 2018-01-26 18:25:14 -05:00
statistics Fix bogus code for extracting extended-statistics data from syscache. 2018-05-02 12:23:00 -04:00
storage Make autovacuum more aggressive to remove orphaned temp tables 2018-08-13 11:49:04 +02:00
tcop Don't run atexit callbacks in quickdie signal handlers. 2018-08-08 19:10:32 +03:00
tsearch Hand code string to integer conversion for performance. 2018-07-22 14:58:23 -07:00
utils Clean up assorted misuses of snprintf()'s result value. 2018-08-15 16:29:31 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Rearrange makefile rules for running Gen_fmgrtab.pl. 2018-05-03 17:54:18 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Translation updates 2018-06-25 12:37:18 +02:00