summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerge Hallyn <serge@hallyn.com>2023-02-24 13:52:32 -0600
committerSerge Hallyn <serge@hallyn.com>2023-02-24 13:54:54 -0600
commit7ff33fae6f9cd79c0e012671c37a172e9a681d0b (patch)
tree6cf1ed3328849cbd87546c8eb1f36e136d67bab5
parent17efd5925235685b59be1c267d0dfad7a9bb62b8 (diff)
get_pidfd_from_fd: return -1 on error, not 0
Fixes: 6974df39a: newuidmap and newgidmap: support passing pid as fd Signed-off-by: Serge Hallyn <serge@hallyn.com>
-rw-r--r--lib/get_pid.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/get_pid.c b/lib/get_pid.c
index ab91d158..5b6d9da4 100644
--- a/lib/get_pid.c
+++ b/lib/get_pid.c
@@ -35,6 +35,7 @@ int get_pid (const char *pidstr, pid_t *pid)
/*
* If use passed in fd:4 as an argument, then return the
* value '4', the fd to use.
+ * On error, return -1.
*/
int get_pidfd_from_fd(const char *pidfdstr)
{
@@ -47,7 +48,7 @@ int get_pidfd_from_fd(const char *pidfdstr)
|| ('\0' != *endptr)
|| (ERANGE == errno)
|| (/*@+longintegral@*/val != (pid_t)val)/*@=longintegral@*/) {
- return 0;
+ return -1;
}
return (int)val;