From owner-freebsd-doc@freebsd.org Tue Jan 12 22:34:13 2016 Return-Path: Delivered-To: freebsd-doc@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 E5940A80F37 for ; Tue, 12 Jan 2016 22:34:12 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (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 CB96B1175 for ; Tue, 12 Jan 2016 22:34:12 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id u0CMYBRC059770 for ; Tue, 12 Jan 2016 22:34:12 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-doc@FreeBSD.org Subject: [Bug 206176] Non-null-terminated arrays in descriptions of strn* and wcsn* functions Date: Tue, 12 Jan 2016 22:34:12 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Documentation X-Bugzilla-Component: Documentation X-Bugzilla-Version: Latest X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: cherepan@mccme.ru X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-doc@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jan 2016 22:34:13 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D206176 Bug ID: 206176 Summary: Non-null-terminated arrays in descriptions of strn* and wcsn* functions Product: Documentation Version: Latest Hardware: Any OS: Any Status: New Severity: Affects Many People Priority: --- Component: Documentation Assignee: freebsd-doc@FreeBSD.org Reporter: cherepan@mccme.ru The strn* and wcsn* functions take an argument limiting the size of process= ed parts of arrays. The C standard cautiously and consistently talks about arr= ays instead of strings in such cases and (hence) doesn't require arguments to be null-terminated strings in all cases. OTOH FreeBSD man pages don't make this distinction and don't usually make remarks to that effect. Take for example strcmp and strncmp. The description of strcmp in C11, 7.24.4.2p2: "The strcmp function compares the string pointed to by s1 to the string poi= nted to by s2." It talks about "the string pointed to by s1" as expected. Then, the description of strncmp -- C11, 7.24.4.4p2: "The strncmp function compares not more than n characters (characters that follow a null character are not compared) from the array pointed to by s1 to the array pointed to by s2." Here, it talks about "the array pointed to by s1" instead of strings. In the next paragraph it talks about "the possibly null-terminated array pointed to by s1" (please note "possibly"). The man page[1] for strncmp is silent on such details. The same for strncat[2]. The question for non-C11 function like strncasecmp[3], strndup[4], strnstr[= 5] is moot but IMHO it's better to be consistent with C11. Implementations are mostly ok, only documentation is wrong. [1] https://svnweb.freebsd.org/base/head/lib/libc/string/strcmp.3?revision=3D25= 1069&view=3Dmarkup#l51 [2] https://svnweb.freebsd.org/base/head/lib/libc/string/strcat.3?revision=3D26= 2890&view=3Dmarkup#l51 [3] https://svnweb.freebsd.org/base/head/lib/libc/string/strcasecmp.3?revision= =3D266865&view=3Dmarkup#l55 [4] https://svnweb.freebsd.org/base/head/lib/libc/string/strdup.3?revision=3D25= 1069&view=3Dmarkup#l63 [5] https://svnweb.freebsd.org/base/head/lib/libc/string/strstr.3?revision=3D25= 1069&view=3Dmarkup#l77 --=20 You are receiving this mail because: You are the assignee for the bug.=