Skip to content

Commit 81256cd

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 a13b47a commit 81256cd

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
@@ -2041,10 +2041,12 @@ auth_peer(hbaPort *port)
20412041
pw = getpwuid(uid);
20422042
if (!pw)
20432043
{
2044+
int save_errno = errno;
2045+
20442046
ereport(LOG,
20452047
(errmsg("could not look up local user ID %ld: %s",
20462048
(long) uid,
2047-
errno ? strerror(errno) : _("user does not exist"))));
2049+
save_errno ? strerror(save_errno) : _("user does not exist"))));
20482050
return STATUS_ERROR;
20492051
}
20502052

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy