From e2ff0ad27390a5b50af914080926304ef8e503cf Mon Sep 17 00:00:00 2001 From: apio Date: Thu, 18 Apr 2024 21:25:36 +0200 Subject: [PATCH] libc: Propagate errors correctly in shadow functions --- libc/src/shadow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libc/src/shadow.cpp b/libc/src/shadow.cpp index 4b3eaa9a..65caa796 100644 --- a/libc/src/shadow.cpp +++ b/libc/src/shadow.cpp @@ -16,7 +16,7 @@ extern "C" { struct spwd* result; - getspent_r(&spwd, s_buf, sizeof(s_buf), &result); + if (getspent_r(&spwd, s_buf, sizeof(s_buf), &result) < 0) return nullptr; return result; } @@ -28,7 +28,7 @@ extern "C" if (!f) { f = fopen("/etc/shadow", "r"); - if (!f) return 0; + if (!f) return -1; fcntl(fileno(f), F_SETFD, FD_CLOEXEC); }