[PATCH] ping6: segfault on incorrect command line

Leonid Lisovskiy lly.dev at gmail.com
Thu Nov 19 17:05:10 UTC 2009


On Thu, Nov 19, 2009 at 6:23 PM, walter harms <wharms at bfs.de> wrote:
> I think it worked because the original was simply:
>  argv[0] = (char*)"-6";
> the argv[-1] trick is a loop to much by using the wrong memory
> the ping_main has this trick here:
>
> #if ENABLE_PING6
>    while ((++argv)[0] && argv[0][0] == '-') {  <-- so the argv-1 is important for ping6
>                if (argv[0][1] == '4') {
>                        af = AF_INET;
>                        continue;
>                }
>                if (argv[0][1] == '6') {
>                        af = AF_INET6;
>                        continue;
>                }
>                bb_show_usage();
Code above used in case of CONFIG_FEATURE_FANCY_PING is off only!

> @leonid:
> i can not reproduce your problem, what version of bb do you use ?

Sorry, i forgot to provide full info:
busybox: 1.15.2

Major part of .config related to ping/ping6:
=========================
CONFIG_PING=y
CONFIG_PING6=y
CONFIG_FEATURE_FANCY_PING=y
=========================

btw. code with argv-1 in ping.c exists since 2007 year

Leonid


More information about the busybox mailing list