]> git.ipfire.org Git - thirdparty/shadow.git/commit
lib/, src/: Fix error handling after strto[u]l[l](3)
authorAlejandro Colomar <alx@kernel.org>
Fri, 1 Dec 2023 18:31:16 +0000 (19:31 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Mon, 4 Dec 2023 11:21:55 +0000 (12:21 +0100)
commit1c464d9a2df7da655eb85f6239beb23527575f9b
treea5358bbfa7e5526c40038c41d2d60f5f8b2efecf
parentf6701d3efa40dd47ff3ab4809dbd4012eb4ce936
lib/, src/: Fix error handling after strto[u]l[l](3)

-  Set errno = 0 before the call.  Otherwise, it may contain anything.
-  ERANGE is not the only possible errno value of these functions.  They
   can also set it to EINVAL.
-  Any errno value after these calls is bad; just compare against 0.
-  Don't check for the return value; just errno.  This function is
   guaranteed to not modify errno on success (POSIX).
-  Check endptr == str, which may or may not set EINVAL.

Suggested-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
12 files changed:
lib/get_gid.c
lib/get_pid.c
lib/get_uid.c
lib/getgr_nam_gid.c
lib/getlong.c
lib/getrange.c
lib/gettime.c
lib/getulong.c
lib/limits.c
lib/prefix_flag.c
src/check_subid_range.c
src/usermod.c