barebox crashes with CONFIG_CMD_MAGICVAR=y and CONFIG_CMD_MAGICVAR_HELP unset
Sascha Hauer
s.hauer at pengutronix.de
Thu Sep 8 23:25:41 PDT 2016
On Thu, Sep 08, 2016 at 09:27:52PM +0200, Uwe Kleine-König wrote:
> Hello,
>
> with
>
> CONFIG_CMD_MAGICVAR=y
> # CONFIG_CMD_MAGICVAR_HELP is not set
>
> calling magicvar results in
>
> md->description = xstrdup(description)
>
> in line 64 of commands/magicvar.c. As CONFIG_CMD_MAGICVAR_HELP is not
> set, description is NULL which makes xstrdup fail.
>
> I fixed it here doing
>
> - md->description = xstrdup(description);
> + md->description = description ? xstrdup(description) : NULL;
>
> but I can imagine other variants:
>
> if (IS_ENABLED(CONFIG_CMD_MAGICVAR_HELP))
> md->description = xstrdup(description);
>
> or fixing xstrdup to not choke on NULL.
>
> What do you prefer?
kstrdup in the kernel tests for NULL and xstrdup in busybox does also.
Let's just add the test.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list