Skip to content

Commit 2e62fa6

Browse files
committed
Avoid core dump after getpwuid_r failure.
Looking up a nonexistent user ID would lead to a null pointer dereference. That's unlikely to happen here, but perhaps not impossible. Thinko in commit 4d5111b, noticed by Coverity.
1 parent d8df7ac commit 2e62fa6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/interfaces/libpq/fe-auth.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ pg_fe_getusername(uid_t user_id, PQExpBuffer errorMessage)
12051205
DWORD namesize = sizeof(username);
12061206
#else
12071207
struct passwd pwbuf;
1208-
struct passwd *pw;
1208+
struct passwd *pw = NULL;
12091209
char buf[1024];
12101210
int rc;
12111211
#endif
@@ -1230,7 +1230,8 @@ pg_fe_getusername(uid_t user_id, PQExpBuffer errorMessage)
12301230
if (errorMessage)
12311231
libpq_append_error(errorMessage, "local user with ID %ld does not exist", (long) user_id);
12321232
}
1233-
name = pw->pw_name;
1233+
else
1234+
name = pw->pw_name;
12341235
#endif
12351236

12361237
if (name)

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