From owner-svn-src-head@freebsd.org Mon Nov 13 17:04:46 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 11BC8DBF738; Mon, 13 Nov 2017 17:04:46 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D2F3675563; Mon, 13 Nov 2017 17:04:45 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vADH4iAX035815; Mon, 13 Nov 2017 17:04:44 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vADH4iZ9035812; Mon, 13 Nov 2017 17:04:44 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201711131704.vADH4iZ9035812@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Mon, 13 Nov 2017 17:04:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r325765 - head/lib/libc/string X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/lib/libc/string X-SVN-Commit-Revision: 325765 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Nov 2017 17:04:46 -0000 Author: imp Date: Mon Nov 13 17:04:44 2017 New Revision: 325765 URL: https://svnweb.freebsd.org/changeset/base/325765 Log: Add notes about overlapping copies. Add notes to each of these that specifically state that results are undefined if the strings overlap. In the case of memcpy, we document the overlapping behavior on FreeBSD (pre-existing). For str*, it is left unspecified, however, since the default (and x86) implementations do not handle overlapping strings properly. PR: 223653 Sponsored by: Netflix Modified: head/lib/libc/string/memcpy.3 head/lib/libc/string/strcat.3 head/lib/libc/string/strcpy.3 Modified: head/lib/libc/string/memcpy.3 ============================================================================== --- head/lib/libc/string/memcpy.3 Mon Nov 13 16:53:36 2017 (r325764) +++ head/lib/libc/string/memcpy.3 Mon Nov 13 17:04:44 2017 (r325765) @@ -54,6 +54,11 @@ bytes from string .Fa src to string .Fa dst . +If +.Fa src +and +.Fa dst +overlap, the results are not defined. .Sh RETURN VALUES The .Fn memcpy Modified: head/lib/libc/string/strcat.3 ============================================================================== --- head/lib/libc/string/strcat.3 Mon Nov 13 16:53:36 2017 (r325764) +++ head/lib/libc/string/strcat.3 Mon Nov 13 17:04:44 2017 (r325765) @@ -62,6 +62,11 @@ then add a terminating The string .Fa s must have sufficient space to hold the result. +If +.Fa s +and +.Fa append +overlap, the results are undefined. .Pp The .Fn strncat @@ -72,6 +77,11 @@ characters from .Fa append , and then adds a terminating .Ql \e0 . +If +.Fa s +and +.Fa append +overlap, the results are undefined. .Sh RETURN VALUES The .Fn strcat Modified: head/lib/libc/string/strcpy.3 ============================================================================== --- head/lib/libc/string/strcpy.3 Mon Nov 13 16:53:36 2017 (r325764) +++ head/lib/libc/string/strcpy.3 Mon Nov 13 17:04:44 2017 (r325765) @@ -63,6 +63,11 @@ to (including the terminating .Ql \e0 character.) +If +.Fa src +and +.Fa dst +overlap, the results are undefined. .Pp The .Fn stpncpy @@ -89,6 +94,11 @@ Otherwise, is .Em not terminated. +If +.Fa src +and +.Fa dst +overlap, the results are undefined. .Sh RETURN VALUES The .Fn strcpy