From tim@robbins.dropbear.id.au  Sat Dec 29 06:11:05 2001
Return-Path: <tim@robbins.dropbear.id.au>
Received: from raven.robbins.dropbear.id.au (185.c.001.mel.iprimus.net.au [203.134.131.185])
	by hub.freebsd.org (Postfix) with ESMTP id F02EC37B41F
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 29 Dec 2001 06:10:58 -0800 (PST)
Received: (from tim@localhost)
	by raven.robbins.dropbear.id.au (8.11.6/8.11.6) id fBTE4sD03874;
	Sun, 30 Dec 2001 01:04:54 +1100 (EST)
	(envelope-from tim)
Message-Id: <200112291404.fBTE4sD03874@raven.robbins.dropbear.id.au>
Date: Sun, 30 Dec 2001 01:04:54 +1100 (EST)
From: "Tim J. Robbins" <tim@robbins.dropbear.id.au>
Reply-To: "Tim J. Robbins" <tim@robbins.dropbear.id.au>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: memcpy(3) could suggest memmove for overlapping copies
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         33298
>Category:       docs
>Synopsis:       memcpy(3) could suggest memmove for overlapping copies
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-doc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 29 06:20:00 PST 2001
>Closed-Date:    Sun Jan 6 22:03:42 PST 2002
>Last-Modified:  Sun Jan 06 22:03:52 PST 2002
>Originator:     Tim J. Robbins
>Release:        FreeBSD 4.5-PRERELEASE i386
>Organization:
>Environment:
System: FreeBSD raven.robbins.dropbear.id.au 4.5-PRERELEASE FreeBSD 4.5-PRERELEASE #2: Thu Dec 27 22:09:06 EST 2001 tim@raven.robbins.dropbear.id.au:/usr/obj/usr/src/sys/RAVEN i386


	
>Description:
From memcpy(3):
BUGS
     In this implementation memcpy() is implemented using bcopy(3), and there-
     fore the strings may overlap.  On other systems, copying overlapping
     strings may produce surprises.  A simpler solution is to not use
     memcpy().

Using memmove() is simpler than not using memcpy().

>How-To-Repeat:
man 3 memcpy
>Fix:

--- memcpy.3.old	Sun Dec 30 00:55:49 2001
+++ memcpy.3	Sun Dec 30 00:59:20 2001
@@ -82,5 +82,10 @@
 .Xr bcopy 3 ,
 and therefore the strings may overlap.
 On other systems, copying overlapping strings may produce surprises.
-A simpler solution is to not use
-.Fn memcpy .
+Programs intended to be portable should use
+.Fn memmove
+when
+.Fa src
+and
+.Fa dst
+may overlap.


.. or something to that effect.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: dd 
State-Changed-When: Sun Jan 6 22:03:42 PST 2002 
State-Changed-Why:  
applied, thanks. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=33298 
>Unformatted:
