<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/lib/libc/string, branch releng/12.4</title>
<subtitle>FreeBSD source tree</subtitle>
<id>https://cgit-dev.freebsd.org/src/atom?h=releng%2F12.4</id>
<link rel='self' href='https://cgit-dev.freebsd.org/src/atom?h=releng%2F12.4'/>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/'/>
<updated>2022-01-19T00:32:56Z</updated>
<entry>
<title>libc: correct SPDX tag on strstr.c</title>
<updated>2022-01-19T00:32:56Z</updated>
<author>
<name>Ed Maste</name>
<email>emaste@FreeBSD.org</email>
</author>
<published>2022-01-16T16:56:28Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=9486fe67b6d753250360218f970485566a1085ae'/>
<id>urn:sha1:9486fe67b6d753250360218f970485566a1085ae</id>
<content type='text'>
It was obtained from musl, and is MIT licensed.

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2e9bc9d14440aa17e6945a9b6613ebb1711fe960)
</content>
</entry>
<entry>
<title>libc: fix misleading comment in strstr</title>
<updated>2022-01-19T00:32:50Z</updated>
<author>
<name>Ed Maste</name>
<email>emaste@FreeBSD.org</email>
</author>
<published>2022-01-16T16:50:10Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=d38fec19012a84838566bb9f6398f89d1801f104'/>
<id>urn:sha1:d38fec19012a84838566bb9f6398f89d1801f104</id>
<content type='text'>
Obtained from:	musl c53e9b239418

(cherry picked from commit c6750f07b43d18d39729570533f4ecb56da286bf)
</content>
</entry>
<entry>
<title>libc: fix undefined behavior from signed overflow in strstr and memmem</title>
<updated>2021-01-15T14:25:35Z</updated>
<author>
<name>Ed Maste</name>
<email>emaste@FreeBSD.org</email>
</author>
<published>2020-11-19T00:03:15Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=56880a50139647318a123d67fe459ca840351729'/>
<id>urn:sha1:56880a50139647318a123d67fe459ca840351729</id>
<content type='text'>
unsigned char promotes to int, which can overflow when shifted left by
24 bits or more. this has been reported multiple times but then
forgotten. it's expected to be benign UB, but can trap when built with
explicit overflow catching (ubsan or similar). fix it now.

note that promotion to uint32_t is safe and portable even outside of
the assumptions usually made in musl, since either uint32_t has rank
at least unsigned int, so that no further default promotions happen,
or int is wide enough that the shift can't overflow. this is a
desirable property to have in case someone wants to reuse the code
elsewhere.

musl commit: 593caa456309714402ca4cb77c3770f4c24da9da

Obtained from:	musl

(cherry picked from commit 33482dae89c26158a22ccb3b7f2ca6e6652f29b4)
</content>
</entry>
<entry>
<title>libc: optimize memmem two-way bad character shift</title>
<updated>2021-01-15T14:25:35Z</updated>
<author>
<name>Ed Maste</name>
<email>emaste@FreeBSD.org</email>
</author>
<published>2020-11-19T00:02:12Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=13bc5a7358e5a39feec12b77b097c70dd111305e'/>
<id>urn:sha1:13bc5a7358e5a39feec12b77b097c70dd111305e</id>
<content type='text'>
first, the condition (mem &amp;&amp; k &lt; p) is redundant, because mem being
nonzero implies the needle is periodic with period exactly p, in which
case any byte that appears in the needle must appear in the last p
bytes of the needle, bounding the shift (k) by p.

second, the whole point of replacing the shift k by mem (=l-p) is to
prevent shifting by less than mem when discarding the memory on shift,
in which case linear time could not be guaranteed. but as written, the
check also replaced shifts greater than mem by mem, reducing the
benefit of the shift. there is no possible benefit to this reduction of
the shift; since mem is being cleared, the full shift is valid and
more optimal. so only replace the shift by mem when it would be less
than mem.

musl commits:
8f5a820d147da36bcdbddd201b35d293699dacd8
122d67f846cb0be2c9e1c3880db9eb9545bbe38c

Obtained from:	musl

(cherry picked from commit 7dbcd06e63101d51e6a777f7315cfde794411e53)
</content>
</entry>
<entry>
<title>clang-format libc string functions imported from musl</title>
<updated>2021-01-15T14:25:35Z</updated>
<author>
<name>Ed Maste</name>
<email>emaste@FreeBSD.org</email>
</author>
<published>2020-11-18T22:01:34Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=e7c49bf5d78cca59832d568c282a296a3f74529f'/>
<id>urn:sha1:e7c49bf5d78cca59832d568c282a296a3f74529f</id>
<content type='text'>
We have adopted these and don't consider them 'contrib' code, so bring
them closer to style(9).  This is a followon to r315467 and r351700.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 4874ddfd373c582d9cd7fe915d2259295d75d1e5)
</content>
</entry>
<entry>
<title>Implement strerror_l().</title>
<updated>2020-12-30T10:44:23Z</updated>
<author>
<name>Konstantin Belousov</name>
<email>kib@FreeBSD.org</email>
</author>
<published>2020-12-16T09:02:09Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=d3912bec58d0b82509a0973cae02f156986d88fa'/>
<id>urn:sha1:d3912bec58d0b82509a0973cae02f156986d88fa</id>
<content type='text'>
PR: 251651

MFC of r368692, r368723
(cherry picked from commit 675079b1ea61b310f3a42cb0d352a49c1780f89a)
(cherry picked from commit 65bf3043365bd86fc5d4d387ad0c42217f11330b)
</content>
</entry>
<entry>
<title>MFC r351700: libc: Use musl's optimized memchr</title>
<updated>2020-11-25T18:36:38Z</updated>
<author>
<name>Ed Maste</name>
<email>emaste@FreeBSD.org</email>
</author>
<published>2020-11-25T18:36:38Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=80530fe42370c233ee9fb601708313d90844338d'/>
<id>urn:sha1:80530fe42370c233ee9fb601708313d90844338d</id>
<content type='text'>
Parentheses added to HASZERO macro to avoid a GCC warning.

Sponsored by:	The FreeBSD Foundation
</content>
</entry>
<entry>
<title>MFC r362495:</title>
<updated>2020-06-29T06:28:01Z</updated>
<author>
<name>Piotr Pawel Stefaniak</name>
<email>pstef@FreeBSD.org</email>
</author>
<published>2020-06-29T06:28:01Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=d720fd04f27aad86dc772bbd3fe01a4c3454472c'/>
<id>urn:sha1:d720fd04f27aad86dc772bbd3fe01a4c3454472c</id>
<content type='text'>
strtok(3): make it easier to find the RETURN VALUES section
</content>
</entry>
<entry>
<title>MFC r362171: libc manpages: various improvements from NetBSD</title>
<updated>2020-06-27T12:12:47Z</updated>
<author>
<name>Gordon Bergling</name>
<email>gbe@FreeBSD.org</email>
</author>
<published>2020-06-27T12:12:47Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=189d5bc266a3ddd4521f0fdb4c51196a49288d90'/>
<id>urn:sha1:189d5bc266a3ddd4521f0fdb4c51196a49288d90</id>
<content type='text'>
- Add STANDARDS and HISTORY sections within the appropriate manpages
- Mention two USENIX papers within kqueue(2) and strlcpy(3)

Reviewed by:	bcr (mentor)
Approved by:	bcr (mentor)
Obtained from:	NetBSD
Differential Revision:	https://reviews.freebsd.org/D24650
</content>
</entry>
<entry>
<title>MFC r350697:</title>
<updated>2019-08-14T19:21:26Z</updated>
<author>
<name>Dimitry Andric</name>
<email>dim@FreeBSD.org</email>
</author>
<published>2019-08-14T19:21:26Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=116248eeeece8ecd1896356b3a4c5d0f983f6a5d'/>
<id>urn:sha1:116248eeeece8ecd1896356b3a4c5d0f983f6a5d</id>
<content type='text'>
Fix a possible segfault in wcsxfrm(3) and wcsxfrm_l(3).

If the length of the source wide character string, passed in via the
"size_t n" parameter, is set to zero, the function should only return
the required length for the destination wide character string.  In this
case, it should *not* attempt to write to the destination, so the "dst"
parameter is permitted to be NULL.

However, when the internally called _collate_wxfrm() function returns an
error, such as when using the "C" locale, as a fallback wcscpy(3) or
wcsncpy(3) are used.  But if the input length is zero, wcsncpy(3) will
be called with a length of -1!  If the "dst" parameter is NULL, this
will immediately result in a segfault, or if "dst" is a valid pointer,
it will most likely result in unexpectedly overwritten memory.

Fix this by explicitly checking for an input length greater than zero,
before calling wcsncpy(3).

Note that a similar situation does not occur in strxfrm(3), the plain
character version of this function, as it uses strlcpy(3) for the error
case.  The strlcpy(3) function does not write to the destination if the
input length is zero.
</content>
</entry>
</feed>
