mirror of
https://github.com/sheumann/hush.git
synced 2025-01-03 00:31:16 +00:00
use bb_strtou() in umask/wait and check errno to see if there was a problem rather than using endp
This commit is contained in:
parent
8ec1c9dc6e
commit
40b8dc410e
11
shell/hush.c
11
shell/hush.c
@ -4892,12 +4892,10 @@ static int builtin_umask(char **argv)
|
|||||||
{
|
{
|
||||||
mode_t new_umask;
|
mode_t new_umask;
|
||||||
const char *arg = argv[1];
|
const char *arg = argv[1];
|
||||||
char *end;
|
|
||||||
if (arg) {
|
if (arg) {
|
||||||
new_umask = strtoul(arg, &end, 8);
|
new_umask = bb_strtou(arg, NULL, 8);
|
||||||
if (*end != '\0' || end == arg) {
|
if (errno)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
new_umask = umask(0);
|
new_umask = umask(0);
|
||||||
printf("%.3o\n", (unsigned) new_umask);
|
printf("%.3o\n", (unsigned) new_umask);
|
||||||
@ -4924,9 +4922,8 @@ static int builtin_wait(char **argv)
|
|||||||
wait(&status);
|
wait(&status);
|
||||||
|
|
||||||
while (argv[1]) {
|
while (argv[1]) {
|
||||||
char *endp;
|
pid_t pid = bb_strtou(argv[1], NULL, 10);
|
||||||
pid_t pid = bb_strtou(argv[1], &endp, 10);
|
if (errno) {
|
||||||
if (*endp) {
|
|
||||||
bb_perror_msg("wait %s", argv[1]);
|
bb_perror_msg("wait %s", argv[1]);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
} else if (waitpid(pid, &status, 0) == pid) {
|
} else if (waitpid(pid, &status, 0) == pid) {
|
||||||
|
Loading…
Reference in New Issue
Block a user