[U-Boot] [PATCH 3/4] bootm: Avoid 256-byte overflow in fixup_silent_linux()

Mike Frysinger vapier at gentoo.org
Thu Oct 20 00:51:10 CEST 2011


On Wednesday 19 October 2011 18:30:58 Doug Anderson wrote:
> --- a/common/cmd_bootm.c
> +++ b/common/cmd_bootm.c
>
> +static char *do_fixup_silent_linux(const char *cmdline)
> +{
> +	int bufsize;

size_t

> +	/*
> +	 * Allocate enough space for:
> +	 * - a copy of the command line
> +	 * - a space
> +	 * - a blank "console=" argument
> +	 * - the '\0'
> +	 *
> +	 * ...we might not need all this space, but it's OK to overallocate a
> +	 * little.
> +	 */
> +	bufsize = strlen(cmdline) + 1 + sizeof("console=");

relying on the sizeof() to include the NUL byte calculation seems like it 
could confuse some.  how about:
	strlen(cmdline) + 1 + strlen("console=") + 1;
gcc should optimize that into a constant anyways.

> +	strcpy(buf, cmdline);
> +	do {
> +		did_remove  = remove_cmdline_param(buf, "console");
> +	} while (did_remove);
> +	add_cmdline_param(buf, "console=", bufsize);

this is different behavior from what was there before.  the previous code only 
removed the first console= and not all of them.  i've relied on this behavior 
in the past, so i'm not sure you should change it.  at least not without a 
dedicated commit rather than merging it with a commit that's supposed to just 
change the code to use the new remove_cmdline_param() helper.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111019/d74723ed/attachment.pgp 


More information about the U-Boot mailing list