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

Mike Frysinger vapier at gentoo.org
Tue May 24 05:47:01 CEST 2011


On Monday, May 23, 2011 18:38:49 Alexander Holler wrote:
> Am 24.05.2011 00:22, schrieb Wolfgang Denk:
> > Alexander Holler 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.
> 
> I've never seen a valid use of strcpy() with a null-pointer in real
> world programs, which we are talking about, except in bugs.

i'm lazy and type "0" all the time for loading files, copying memory, 
displaying things, etc... in u-boot.  i dont feel like retraining my finger 
muscle memory if i dont have to ;).
-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/20110523/8f2a1b98/attachment.pgp 


More information about the U-Boot mailing list