[U-Boot] [PATCH V2] memcpy/memmove: Do not copy to same address

Wolfgang Denk wd at denx.de
Tue May 24 00:22:49 CEST 2011


Dear Alexander Holler,

In message <4DDADBB6.30607 at ahsoftware.de> you wrote:
>
> So you I will look forward to checks for NULL pointers and similiar in 
> all C standard functions implemented in u-boot to circumvent tons of 
> possible real world bugs in all callers of strcpy, strlen, mem* and 
> whatever.

If you think a bit about this, you may find it more difficult than you
expect.  Keep in mind that on most systems supported by U-Boot code
like

	int *p = (int *)0;

	print("*p = %d\n", *p);

is perfectly legal and supposed to work without any problems -
because 0 is a legal address, and it makes perfect senze that commands
like "md" or "cp" can be used to access it.  In the result, strcpy(),
strlen(), mem*() and whatever must beable to work on address 0 likeon
any other address, too.

:-P

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Minds are like parachutes - they only function when open.


More information about the U-Boot mailing list