diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-12 19:28:10 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-12 19:28:10 +0100 |
commit | 6c93b24ce9dfb5c3970178ca2545502a7830716c (patch) | |
tree | ad9e3f32f2bf42d9124f4c694c7bcb03ebf3387f /shell/hush.c | |
parent | e89a241b9ed76aed22bde93f58311db9c159cde2 (diff) | |
download | busybox-w32-6c93b24ce9dfb5c3970178ca2545502a7830716c.tar.gz busybox-w32-6c93b24ce9dfb5c3970178ca2545502a7830716c.tar.bz2 busybox-w32-6c93b24ce9dfb5c3970178ca2545502a7830716c.zip |
hush: fix potential buffer overflow on NOMMU
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/shell/hush.c b/shell/hush.c index 8de8d3c2a..88a7b988a 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -2919,7 +2919,9 @@ static void re_execute_shell(char ***to_free, const char *s, | |||
2919 | char *g_argv0, char **g_argv, | 2919 | char *g_argv0, char **g_argv, |
2920 | char **builtin_argv) | 2920 | char **builtin_argv) |
2921 | { | 2921 | { |
2922 | char param_buf[sizeof("-$%x:%x:%x:%x:%x") + sizeof(unsigned) * 2]; | 2922 | #define NOMMU_HACK_FMT ("-$%x:%x:%x:%x:%x:%llx" IF_HUSH_LOOPS(":%x")) |
2923 | /* delims + 2 * (number of bytes in printed hex numbers) */ | ||
2924 | char param_buf[sizeof(NOMMU_HACK_FMT) + 2 * (sizeof(int)*6 + sizeof(long long)*1)]; | ||
2923 | char *heredoc_argv[4]; | 2925 | char *heredoc_argv[4]; |
2924 | struct variable *cur; | 2926 | struct variable *cur; |
2925 | # if ENABLE_HUSH_FUNCTIONS | 2927 | # if ENABLE_HUSH_FUNCTIONS |
@@ -2953,7 +2955,7 @@ static void re_execute_shell(char ***to_free, const char *s, | |||
2953 | } | 2955 | } |
2954 | } | 2956 | } |
2955 | 2957 | ||
2956 | sprintf(param_buf, "-$%x:%x:%x:%x:%x:%llx" IF_HUSH_LOOPS(":%x") | 2958 | sprintf(param_buf, NOMMU_HACK_FMT |
2957 | , (unsigned) G.root_pid | 2959 | , (unsigned) G.root_pid |
2958 | , (unsigned) G.root_ppid | 2960 | , (unsigned) G.root_ppid |
2959 | , (unsigned) G.last_bg_pid | 2961 | , (unsigned) G.last_bg_pid |
@@ -2962,7 +2964,8 @@ static void re_execute_shell(char ***to_free, const char *s, | |||
2962 | , empty_trap_mask | 2964 | , empty_trap_mask |
2963 | IF_HUSH_LOOPS(, G.depth_of_loop) | 2965 | IF_HUSH_LOOPS(, G.depth_of_loop) |
2964 | ); | 2966 | ); |
2965 | /* 1:hush 2:-$<pid>:<pid>:<exitcode>:<depth> <vars...> <funcs...> | 2967 | #undef NOMMU_HACK_FMT |
2968 | /* 1:hush 2:-$<pid>:<pid>:<exitcode>:<etc...> <vars...> <funcs...> | ||
2966 | * 3:-c 4:<cmd> 5:<arg0> <argN...> 6:NULL | 2969 | * 3:-c 4:<cmd> 5:<arg0> <argN...> 6:NULL |
2967 | */ | 2970 | */ |
2968 | cnt += 6; | 2971 | cnt += 6; |