Commit 81256cd0 authored by Tom Lane's avatar Tom Lane

Fix unsafe usage of strerror(errno) within ereport().

This is the converse of the unsafe-usage-of-%m problem: the reason
ereport/elog provide that format code is mainly to dodge the hazard
of errno getting changed before control reaches functions within the
arguments of the macro.  I only found one instance of this hazard,
but it's been there since 9.4 :-(.
parent a13b47a5
...@@ -2041,10 +2041,12 @@ auth_peer(hbaPort *port) ...@@ -2041,10 +2041,12 @@ auth_peer(hbaPort *port)
pw = getpwuid(uid); pw = getpwuid(uid);
if (!pw) if (!pw)
{ {
int save_errno = errno;
ereport(LOG, ereport(LOG,
(errmsg("could not look up local user ID %ld: %s", (errmsg("could not look up local user ID %ld: %s",
(long) uid, (long) uid,
errno ? strerror(errno) : _("user does not exist")))); save_errno ? strerror(save_errno) : _("user does not exist"))));
return STATUS_ERROR; return STATUS_ERROR;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment