diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-03-29 00:50:30 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-03-29 00:50:30 +0000 |
commit | 40b8dc410e12e6111b2897f385847a0f3ec720c7 (patch) | |
tree | 6b4658685e3f61151712fefd570084990efaa94e | |
parent | 8ec1c9dc6ead6605dd8e88d407e0c84a4d309818 (diff) | |
download | busybox-w32-40b8dc410e12e6111b2897f385847a0f3ec720c7.tar.gz busybox-w32-40b8dc410e12e6111b2897f385847a0f3ec720c7.tar.bz2 busybox-w32-40b8dc410e12e6111b2897f385847a0f3ec720c7.zip |
use bb_strtou() in umask/wait and check errno to see if there was a problem rather than using endp
-rw-r--r-- | shell/hush.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/shell/hush.c b/shell/hush.c index 9f0e7f809..5203f2eef 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -4892,12 +4892,10 @@ static int builtin_umask(char **argv) | |||
4892 | { | 4892 | { |
4893 | mode_t new_umask; | 4893 | mode_t new_umask; |
4894 | const char *arg = argv[1]; | 4894 | const char *arg = argv[1]; |
4895 | char *end; | ||
4896 | if (arg) { | 4895 | if (arg) { |
4897 | new_umask = strtoul(arg, &end, 8); | 4896 | new_umask = bb_strtou(arg, NULL, 8); |
4898 | if (*end != '\0' || end == arg) { | 4897 | if (errno) |
4899 | return EXIT_FAILURE; | 4898 | return EXIT_FAILURE; |
4900 | } | ||
4901 | } else { | 4899 | } else { |
4902 | new_umask = umask(0); | 4900 | new_umask = umask(0); |
4903 | printf("%.3o\n", (unsigned) new_umask); | 4901 | printf("%.3o\n", (unsigned) new_umask); |
@@ -4924,9 +4922,8 @@ static int builtin_wait(char **argv) | |||
4924 | wait(&status); | 4922 | wait(&status); |
4925 | 4923 | ||
4926 | while (argv[1]) { | 4924 | while (argv[1]) { |
4927 | char *endp; | 4925 | pid_t pid = bb_strtou(argv[1], NULL, 10); |
4928 | pid_t pid = bb_strtou(argv[1], &endp, 10); | 4926 | if (errno) { |
4929 | if (*endp) { | ||
4930 | bb_perror_msg("wait %s", argv[1]); | 4927 | bb_perror_msg("wait %s", argv[1]); |
4931 | return EXIT_FAILURE; | 4928 | return EXIT_FAILURE; |
4932 | } else if (waitpid(pid, &status, 0) == pid) { | 4929 | } else if (waitpid(pid, &status, 0) == pid) { |