[PATCH v2 3/7] string/test-str*cmp: remove stupid_[strcmp, strncmp, wcscmp, wcsncmp].

Florian Weimer fweimer@redhat.com
Mon Jan 10 12:42:31 GMT 2022


* Wilco Dijkstra via Libc-alpha:

> Hi Noah,
>
>> These implementations are incorrect. There may be a mismatch in s1/s2
>> before invalid memory but no null CHAR / length boundary.
>
> This is not true, see
> eg. https://en.cppreference.com/w/cpp/string/byte/strcmp.  Most string
> functions require that the string is correctly terminated. There are
> only a few exceptions (memchr IIRC), and several generic
> implementations use strlen or strnlen before the main loop.

I am not sure if those are bugs.  Don't we support non-array usage in
these functions as an extension?  At least for strncmp and strnlen and
their wide counterparts.  C11 is pretty clear that strncmp operates on
arrays, so this is an extension.

Thanks,
Florian



More information about the Libc-alpha mailing list