summaryrefslogtreecommitdiff
path: root/lib/libc/string/strstr.c
Commit message (Collapse)AuthorAgeFilesLines
* libc: fix undefined behavior from signed overflow in strstr and memmemEd Maste2020-11-191-4/+4
| | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=367823
* clang-format libc string functions imported from muslEd Maste2020-11-181-57/+90
| | | | | | | | | | | 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. MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=367821
* libc: update strstr implementation to match muslEd Maste2019-04-091-2/+1
| | | | | | | | | | | | | | | musl commits: 122d67f846cb0be2c9e1c3880db9eb9545bbe38c 0239cd0681e889a269fb7691f60e81ef8d081e6b 8f5a820d147da36bcdbddd201b35d293699dacd8 Submitted by: David CARLIER <devnexen_gmail.com> Obtained from: musl MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D19834 Notes: svn path=/head/; revision=346054
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* libc: add reference to two-way algorithm and bad shift table in memmem/strstrEd Maste2017-03-181-0/+8
| | | | | | | Requested by: ed Notes: svn path=/head/; revision=315468
* libc: Use musl's O(n) memmem and strstrEd Maste2017-03-181-48/+167
| | | | | | | | | | | | | | | | | | | | | | It is O(n) in the length of the haystack (big) string, and has special cases for short needle (little) strings, of one to four bytes, to avoid excessive overhead. There are a small set of nearly trivial cases where the startup overhead of the musl implementation makes it slightly slower -- for example, a 31 byte needle that matches the beginning of the haystack. It's faster for non-trivial cases, and significantly so for inputs that trigger worst- case behaviour of the previous implementation. As an example, in my tests a 16K needle that matches the end of a 64K haystack is nearly 2000x faster with this implementation. Reviewed by: bapt (earlier), ed (earlier) Obtained from: musl (snapshot at commit c718f9fc) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D2601 Notes: svn path=/head/; revision=315467
* Renumber clauses to reduce diffs to other versionsEd Maste2013-05-281-1/+1
| | | | | | | | NetBSD, OpenBSD, and Android's Bionic number the clauses 1 through 3, so follow suit to make comparison easier. Notes: svn path=/head/; revision=251069
* - ANSIfy function definitionsDaniel Gerzo2009-02-031-4/+3
| | | | | | | | | - use nul when we are looking for a terminating character where appropriate Approved by: imp Notes: svn path=/head/; revision=188080
* Per Regents of the University of Calfornia letter, remove advertisingWarner Losh2007-01-091-4/+0
| | | | | | | | | clause. # If I've done so improperly on a file, please let me know. Notes: svn path=/head/; revision=165903
* Remove 'register' keyword.David E. O'Brien2002-03-211-3/+3
| | | | Notes: svn path=/head/; revision=92889
* rcsid[]->__FBSDIDDavid E. O'Brien2001-11-071-5/+2
| | | | Notes: svn path=/head/; revision=86170
* Make the rcsid and FreeBSD IDs more sane in the wcs* and wmem* files.David E. O'Brien2001-05-241-0/+4
| | | | | | | Do the same for the non-wcs*/wmem* files while I'm here. Notes: svn path=/head/; revision=77117
* BSD 4.4 Lite Lib SourcesRodney W. Grimes1994-05-271-0/+65
Notes: svn path=/cvs2svn/branches/unlabeled-1.1.1/; revision=1573