Date: Sun, 30 Dec 2001 01:04:54 +1100 (EST) From: "Tim J. Robbins" <tim@robbins.dropbear.id.au> To: FreeBSD-gnats-submit@freebsd.org Subject: docs/33298: memcpy(3) could suggest memmove for overlapping copies Message-ID: <200112291404.fBTE4sD03874@raven.robbins.dropbear.id.au>
next in thread | raw e-mail | index | archive | help
>Number: 33298
>Category: docs
>Synopsis: memcpy(3) could suggest memmove for overlapping copies
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-doc
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sat Dec 29 06:20:00 PST 2001
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-doc" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200112291404.fBTE4sD03874>
