[PATCH] watch: don't leak cmd (-8 bytes; -16 on arm)

Denys Vlasenko vda.linux at googlemail.com
Fri Oct 22 14:59:57 UTC 2010


On Fri, Oct 22, 2010 at 3:38 PM, Alexander Shishkin <virtuoso at slind.org> wrote:
> Signed-off-by: Alexander Shishkin <virtuoso at slind.org>
> ---
>  procps/watch.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/procps/watch.c b/procps/watch.c
> index 36f71c4..0d1118d 100644
> --- a/procps/watch.c
> +++ b/procps/watch.c
> @@ -47,7 +47,7 @@ int watch_main(int argc UNUSED_PARAM, char **argv)
>        // watch ls -l "a /tmp" "2>&1" - ls won't see "a /tmp" as one param
>        cmd = *argv;
>        while (*++argv)
> -               cmd = xasprintf("%s %s", cmd, *argv); // leaks cmd
> +               *(*argv - 1) = ' ';

Bug. getopt reorders argv[].

-- 
vda


More information about the busybox mailing list