Content-Length: 275840 | pFad | http://github.com/postgrespro/postgres/commit/2e62fa62d6745ba3bcb0a517d002aff1f3cdefb7

DF Avoid core dump after getpwuid_r failure. · postgrespro/postgres@2e62fa6 · GitHub
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/2e62fa62d6745ba3bcb0a517d002aff1f3cdefb7

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy