[PATCH] fixup! setenv: align with POSIX in handling of setenv(var, "")

Sascha Hauer s.hauer at pengutronix.de
Mon Nov 16 03:21:17 EST 2020


On Fri, Nov 13, 2020 at 09:26:00AM +0100, Ahmad Fatoum wrote:
> Previously setenv xxx= deleted x like xxx= does. With xxx= now instead
> assigning the empty string, setenv xxx= should too.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> 
> ---
>  commands/setenv.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/commands/setenv.c b/commands/setenv.c
> index 6992f604f513..9aeb8f010bc5 100644
> --- a/commands/setenv.c
> +++ b/commands/setenv.c
> @@ -18,8 +18,7 @@ static int do_setenv(int argc, char *argv[])
>  	equal = strrchr(argv[1], '=');
>  	if (equal) {
>  		equal[0] = '\0';
> -		if (equal[1])
> -			argv[2] = &equal[1];
> +		argv[2] = &equal[1];
>  	}

Fine with me, but I just had a second look at fbf145dc86 ("commands: setenv:
support setenv dev.var=VAL syntax"). This patch introduced using argv[2]
when argc was only to, thus only argv[0] and argv[1] are valid. I wonder
if this is allowed. KAsan doesn't complain, but still I think this
should be changed. Could you do this before further modifying this?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list