[Bug string/19391] strnlen invokes UB by adding maxlen to str

cherepan at mccme dot ru sourceware-bugzilla@sourceware.org
Wed Dec 30 10:33:00 GMT 2015


https://sourceware.org/bugzilla/show_bug.cgi?id=19391

--- Comment #4 from Alexander Cherepanov <cherepan at mccme dot ru> ---
On 2015-12-28 17:18, cherepan at mccme dot ru wrote:
> (In reply to Florian Weimer from comment #1)
>> Isn't strnlen (p, -1) equivalent to strlen (p)?  It's difficult to tell from
>> the specification.
>
> 1. I'm not sure what you mean.

Ok, I think I found the reason of the confusion. I was looking at glibc 
manual as available on https://www.gnu.org/ but manual/string.texi was 
modified recently. In particular, the description of strnlen was changed 
by [1]. The current description[2] indeed talks about "the array @var{s} 
of size @var{maxlen}". IMHO this is plainly wrong (and contradicts the 
use of strnlen in glibc itself).

[1] 
https://sourceware.org/git/?p=glibc.git;a=commit;h=2cc4b9cce51643ec299e97450ccde4deeecfb083
[2] 
https://sourceware.org/git/?p=glibc.git;a=blob;f=manual/string.texi;h=016fd0b9a05f3126a1594e942c5e6da0669d0410;hb=HEAD#l313

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Glibc-bugs mailing list