In pg_log_generic(), be more paranoid about preserving errno.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: cf665ad4c89eb9b20285dc04aec906d46ed810d2
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2019-07-06T15:25:48Z
Releases: 12.0
In pg_log_generic(), be more paranoid about preserving errno.

This code failed to account for the possibility that malloc() would
change errno, resulting in wrong output for %m, not to mention the
possibility of message truncation.  Such a change is obviously
expected when malloc fails, but there's reason to fear that on some
platforms even a successful malloc call can modify errno.

Discussion: https://postgr.es/m/2576.1527382833@sss.pgh.pa.us

Files

PathChange+/−
src/common/logging.c modified +2 −0

Discussion