]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
get_pidfd_from_fd: return -1 on error, not 0
authorSerge Hallyn <serge@hallyn.com>
Fri, 24 Feb 2023 19:52:32 +0000 (13:52 -0600)
committerSerge Hallyn <serge@hallyn.com>
Fri, 24 Feb 2023 19:54:54 +0000 (13:54 -0600)
Fixes: 6974df39a: newuidmap and newgidmap: support passing pid as fd
Signed-off-by: Serge Hallyn <serge@hallyn.com>
lib/get_pid.c

index ab91d1585a09cc347a460a0019e88f27876c0804..5b6d9da40b52a6e63aaebb9395c30d428a563422 100644 (file)
@@ -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;