libc: Propagate errors correctly in shadow functions
All checks were successful
Build and test / build (push) Successful in 2m58s

This commit is contained in:
apio 2024-04-18 21:25:36 +02:00
parent 62cb53069c
commit e2ff0ad273
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -16,7 +16,7 @@ extern "C"
{ {
struct spwd* result; 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; return result;
} }
@ -28,7 +28,7 @@ extern "C"
if (!f) if (!f)
{ {
f = fopen("/etc/shadow", "r"); f = fopen("/etc/shadow", "r");
if (!f) return 0; if (!f) return -1;
fcntl(fileno(f), F_SETFD, FD_CLOEXEC); fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
} }