diff options
| author | ookami <110040049+OkamiW@users.noreply.github.com> | 2024-11-17 18:24:16 +0800 |
|---|---|---|
| committer | Simon Ser <contact@emersion.fr> | 2024-11-17 19:15:58 +0100 |
| commit | fbc5a8136187491e5ee3071e8a60e6593ca9b90b (patch) | |
| tree | 25cb5fd781e93ec584b302ba57989a17de60e0a5 | |
| parent | 96f0a0f9c6a9412fc1886bf54e37ece75b0e9f99 (diff) | |
Fix potential NULL deference after getpwuid
This can happen if swaylock is mistakenly run inside a sandbox
without /etc/passwd
| -rw-r--r-- | pam.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -72,6 +72,11 @@ static const char *get_pam_auth_error(int pam_status) { void run_pw_backend_child(void) { struct passwd *passwd = getpwuid(getuid()); + if (!passwd) { + swaylock_log_errno(LOG_ERROR, "getpwuid failed"); + exit(EXIT_FAILURE); + } + char *username = passwd->pw_name; const struct pam_conv conv = { |
