lib/, src/: Replace strtou[l]l(3) by strtou[l]l_noneg()
strtou[l]l(3) silently converts negative numbers into positive. This behavior is wrong: a negative value should be parsed as a negative value, which would underflow unsigned (long) long, and so would return the smallest possible value, 0, and set errno to ERANGE to report an error. Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com> Cc: "Serge E. Hallyn" <serge@hallyn.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
4a2646f676
commit
f14670ee1a
@@ -12,6 +12,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "atoi/strtou_noneg.h"
|
||||
#include "defines.h"
|
||||
#include "prototypes.h"
|
||||
#include "subordinateio.h"
|
||||
@@ -35,10 +37,10 @@ int main(int argc, char **argv)
|
||||
owner = argv[1];
|
||||
check_uids = argv[2][0] == 'u';
|
||||
errno = 0;
|
||||
start = strtoul(argv[3], NULL, 10);
|
||||
start = strtoul_noneg(argv[3], NULL, 10);
|
||||
if (errno != 0)
|
||||
exit(1);
|
||||
count = strtoul(argv[4], NULL, 10);
|
||||
count = strtoul_noneg(argv[4], NULL, 10);
|
||||
if (errno != 0)
|
||||
exit(1);
|
||||
if (check_uids) {
|
||||
|
||||
Reference in New Issue
Block a user