Re: barebox crashes with CONFIG_CMD_MAGICVAR=y and CONFIG_CMD_MAGICVAR_HELP unset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 |

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux