diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-08-23 23:15:17 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-08-23 23:15:17 +0000 |
commit | 7fe21c69cdfbe3863aa69f40df6bbbe7abe4af8d (patch) | |
tree | 6c31b5c3afac40894ce0fc1ed563c5be02c82258 | |
parent | 6cd36bc2dab71646582564ad7c64494e05fd2af4 (diff) | |
download | busybox-w32-7fe21c69cdfbe3863aa69f40df6bbbe7abe4af8d.tar.gz busybox-w32-7fe21c69cdfbe3863aa69f40df6bbbe7abe4af8d.tar.bz2 busybox-w32-7fe21c69cdfbe3863aa69f40df6bbbe7abe4af8d.zip |
setarch: do not try to use non-existent data in argv[]
-rw-r--r-- | util-linux/setarch.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/util-linux/setarch.c b/util-linux/setarch.c index 250a93823..8213382e4 100644 --- a/util-linux/setarch.c +++ b/util-linux/setarch.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * Linux32/linux64 allows for changing uname emulation. | 3 | * linux32/linux64 allows for changing uname emulation. |
4 | * | 4 | * |
5 | * Copyright 2002 Andi Kleen, SuSE Labs. | 5 | * Copyright 2002 Andi Kleen, SuSE Labs. |
6 | * | 6 | * |
@@ -14,32 +14,32 @@ | |||
14 | int setarch_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 14 | int setarch_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
15 | int setarch_main(int argc UNUSED_PARAM, char **argv) | 15 | int setarch_main(int argc UNUSED_PARAM, char **argv) |
16 | { | 16 | { |
17 | int pers = -1; | 17 | int pers; |
18 | 18 | ||
19 | /* Figure out what personality we are supposed to switch to ... | 19 | /* Figure out what personality we are supposed to switch to ... |
20 | * we can be invoked as either: | 20 | * we can be invoked as either: |
21 | * argv[0],argv[1] -> "setarch","personality" | 21 | * argv[0],argv[1] == "setarch","personality" |
22 | * argv[0] -> "personality" | 22 | * argv[0] == "personality" |
23 | */ | 23 | */ |
24 | retry: | 24 | if (ENABLE_SETARCH && applet_name[0] == 's' |
25 | if (argv[0][5] == '6') /* linux64 */ | 25 | && argv[1] && strncpy(argv[1], "linux", 5) |
26 | ) { | ||
27 | applet_name = argv[1]; | ||
28 | argv++; | ||
29 | } | ||
30 | if (applet_name[5] == '6') /* linux64 */ | ||
26 | pers = PER_LINUX; | 31 | pers = PER_LINUX; |
27 | else if (argv[0][5] == '3') /* linux32 */ | 32 | else if (applet_name[5] == '3') /* linux32 */ |
28 | pers = PER_LINUX32; | ||
29 | else if (pers == -1 && argv[1] != NULL) { | ||
30 | pers = PER_LINUX32; | 33 | pers = PER_LINUX32; |
31 | ++argv; | 34 | else |
32 | goto retry; | 35 | bb_show_usage(); |
33 | } | ||
34 | 36 | ||
35 | /* make user actually gave us something to do */ | 37 | argv++; |
36 | ++argv; | ||
37 | if (argv[0] == NULL) | 38 | if (argv[0] == NULL) |
38 | bb_show_usage(); | 39 | bb_show_usage(); |
39 | 40 | ||
40 | /* Try to set personality */ | 41 | /* Try to set personality */ |
41 | if (personality(pers) >= 0) { | 42 | if (personality(pers) >= 0) { |
42 | |||
43 | /* Try to execute the program */ | 43 | /* Try to execute the program */ |
44 | BB_EXECVP(argv[0], argv); | 44 | BB_EXECVP(argv[0], argv); |
45 | } | 45 | } |