Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1545ca9

Browse files
committed
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 :-(.
1 parent 9c515f7 commit 1545ca9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/backend/libpq/auth.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,10 +1752,12 @@ auth_peer(hbaPort *port)
17521752
pw = getpwuid(uid);
17531753
if (!pw)
17541754
{
1755+
int save_errno = errno;
1756+
17551757
ereport(LOG,
17561758
(errmsg("could not look up local user ID %ld: %s",
17571759
(long) uid,
1758-
errno ? strerror(errno) : _("user does not exist"))));
1760+
save_errno ? strerror(save_errno) : _("user does not exist"))));
17591761
return STATUS_ERROR;
17601762
}
17611763

0 commit comments

Comments
 (0)