summaryrefslogtreecommitdiff
path: root/lib/libc/string
Commit message (Collapse)AuthorAgeFilesLines
* Revert r330897:Eitan Adler2018-03-2972-160/+16
| | | | | | | | | | | | | | | | | | | | This was intended to be a non-functional change. It wasn't. The commit message was thus wrong. In addition it broke arm, and merged crypto related code. Revert with prejudice. This revert skips files touched in r316370 since that commit was since MFCed. This revert also skips files that require $FreeBSD$ property changes. Thank you to those who helped me get out of this mess including but not limited to gonzo, kevans, rgrimes. Requested by: gjb (re) Notes: svn path=/stable/11/; revision=331722
* Partial merge of the SPDX changesEitan Adler2018-03-1472-16/+160
| | | | | | | | | | These changes are incomplete but are making it difficult to determine what other changes can/should be merged. No objections from: pfg Notes: svn path=/stable/11/; revision=330897
* MFC r329361:Cy Schubert2018-02-242-3/+63
| | | | | | | | | | | | | | | | | | | Document memset_s(3). memset_s(3) is defined in C11 standard (ISO/IEC 9899:2011) K.3.7.4.1 The memset_s function (p: 621-622) Fix memset(3) portion of the man page by replacing the first argument (destination) "b" with "dest", which is more descriptive than "b". This also makes it consistent with the term used in the memset_s() portion of the man page. See also http://en.cppreference.com/w/c/string/byte/memset. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D13682 Notes: svn path=/stable/11/; revision=329919
* MFC r322427:Konstantin Belousov2017-08-191-4/+7
| | | | | | | Improve standard compliance for memset_s() and abort_handler_s(). Notes: svn path=/stable/11/; revision=322692
* MFC r322426:Konstantin Belousov2017-08-151-1/+1
| | | | | | | Fix indent. Notes: svn path=/stable/11/; revision=322533
* MFC r304106:Xin LI2017-05-317-5/+196
| | | | | | | | | | Add timingsafe_bcmp and timingsafe_memcmp. Obtained from: OpenBSD Reviewed by: trasz Notes: svn path=/stable/11/; revision=319292
* MFC r317034:Baptiste Daroussin2017-05-011-58/+62
| | | | | | | | | | | | | | | | | | | | Fix strcoll_l disagreeing with strxfrm by reworking the forward order case in wcscoll_l(). Illumos fixed this while grabbing back our patches: https://www.illumos.org/rb/r/402/ This does not 100% fix what postgresql folks reported as there is still a remaining issue: https://www.illumos.org/issues/7962, it improves the situation The initial issue was reported in postgresql mailing lists: https://www.postgresql.org/message-id/flat/111D0E27-A8F3-4A84-A4E0-B0FB703863DF@s24.com#111D0E27-A8F3-4A84-A4E0-B0FB703863DF@s24.com Submitted by: Yuri Pankov <yuri.pankov@nexenta.com> Obtained from: Illumos Notes: svn path=/stable/11/; revision=317647
* MFC r316213:Konstantin Belousov2017-04-233-1/+68
| | | | | | | | | | | Implement the memset_s(3) function as specified by the C11 ISO/IEC 9899:2011 Appendix K 3.7.4.1. MFC r316258: Only activate __EXT1_VISIBLE block when using sys/errno.h in userspace. Notes: svn path=/stable/11/; revision=317342
* MFC r312332,r312446,r312451:Enji Cooper2017-02-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r312332: Use SRCTOP where possible and use :H to manipulate .CURDIR to get rid of unnecessarily long relative path .PATH values with make r312446 (by emaste): libc: remove reference to nonexistent lib/locale directory As far as I can tell this was introduced in r72406 and updated in several subsequent revisions, but the lib/locale directory it referenced never existed. r312451: Replace dot-dot relative pathing with SRCTOP-relative paths where possible This reduces build output, need for recalculating paths, and makes it clearer which paths are relative to what areas in the source tree. The change in performance over a locally mounted UFS filesystem was negligible in my testing, but this may more positively impact other filesystems like NFS. LIBC_SRCTOP was left alone so Juniper (and other users) can continue to manipulate lib/libc/Makefile (and other Makefile.inc's under lib/libc) as include Makefiles with custom options. Discussed with: marcel, sjg Notes: svn path=/stable/11/; revision=313240
* libc: spelling fixes.Pedro F. Giffuni2016-04-301-1/+1
| | | | | | | Mostly on comments. Notes: svn path=/head/; revision=298830
* Make it clear that the "size" argument is for the dst string.Bryan Drewery2016-02-261-3/+3
| | | | | | | | | | | The rest of the manpage already referenced 'dstsize' but did not rename the variable in the prototype in r257646. MFC after: 3 days Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=296128
* Add a standards compliance note for strtok_r as suggested by cpercival.Warren Block2016-01-221-1/+6
| | | | | | | | Reviewed by: cpercival MFC after: 1 week Notes: svn path=/head/; revision=294597
* Avoid reading pass the end of the source buffer when it is not NULBrooks Davis2016-01-131-1/+1
| | | | | | | | | | | | | | terminated. If this buffer is adjacent to an unmapped page or a version of C with bounds checked is used this may result in a crash. PR: 206178 Submitted by: Alexander Cherepanov <cherepan@mccme.ru> MFC after: 1 week Notes: svn path=/head/; revision=293856
* Avoid reading pass the end of the source buffer when it is not NULBrooks Davis2016-01-131-1/+1
| | | | | | | | | | | | | | terminated. If this buffer is adjacent to an unmapped page or a version of C with bounds checked is used this may result in a crash. PR: 206177 Submitted by: Alexander Cherepanov <cherepan@mccme.ru> MFC after: 1 week Notes: svn path=/head/; revision=293855
* collate: Fix expansion substitions (broken upstream too)Baptiste Daroussin2015-10-231-40/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Through testing, the user noted that some Cyrillic characters were not sorting correctly, and this was confirmed. After extensive testing and review, the localedef tool was eliminated as the culprit. The sustitutions were encoded correctly in LC_COLLATE. The error was mainly in wcscoll where character expansions were mishandled. The main directive pass routines had to be written to go back for a new collation value when the "state" variable was set. Before pointers were being advanced, the second lookup was gettting applied to the wrong character, etc. The "eat expansion codes" section on collate.c also had a bug. Later own, the "state" variable logic was changed to only set if next code was greater than zero (rather than >= 0). Some additional cleanups got captured from previous work: 1) The previous commit moved the binary search comment from the correct location to a wrong location because it's wrong upstream in Illumos. The comment has little value so I just removed it. 2) Don't check if pointers are null before freeing, this is redundant as free() handles null pointers. 3) The two binary search trees were standardized wrt initialization 4) On the binary search trees, a negative "high" exits rather than checking the table count again. Submitted by: marino Obtained from: DragonflyBSD Notes: svn path=/projects/collation/; revision=289860
* Merge from headBaptiste Daroussin2015-10-191-2/+3
|\ | | | | | | Notes: svn path=/projects/collation/; revision=289573
| * Document bitset(9)Conrad Meyer2015-10-171-2/+3
| | | | | | | | Notes: svn path=/head/; revision=289467
* | Merge from headBaptiste Daroussin2015-10-132-33/+24
|\| | | | | | | Notes: svn path=/projects/collation/; revision=289256
| * Add declaration to eliminate -Wmissing-prototypes warning.Craig Rodrigues2015-09-201-0/+2
| | | | | | | | Notes: svn path=/head/; revision=288004
| * Replace strndup with OpenBSD's implementation.Xin LI2015-08-261-33/+22
| | | | | | | | | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=287181
* | Merge from HEADBaptiste Daroussin2015-08-252-2/+31
|\| | | | | | | Notes: svn path=/projects/collation/; revision=287142
| * Fix spelling.Marcelo Araujo2015-08-241-2/+1
| | | | | | | | | | | | | | | | | | Reviewed by: wblock, pfg Approved by: bapt (mentor) Differential Revision: D3380 Notes: svn path=/head/; revision=287089
| * Update bzero(3) manpage to following the Posix Standard.Marcelo Araujo2015-08-241-1/+9
| | | | | | | | | | | | | | | | | | Reviewed by: wblock, pfg Approved by: bapt (mentor) Differential Revision: D3380 Notes: svn path=/head/; revision=287088
| * Make clear the bcopy(3) manpage regards when it was marked as LEGACYMarcelo Araujo2015-08-141-13/+23
| | | | | | | | | | | | | | | | | | | | | | as well as when it was removed from POSIX specification. Reviewed by: theraven, wblock, bapt, rodrigc Approved by: bapt, rodrigc (mentor) Differential Revision: D3374 Notes: svn path=/head/; revision=286757
| * Remove the mention of memcpy(3) that is build on top of bcopy(3).Marcelo Araujo2015-08-131-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Fix some phrases to make it more clear. Differential Revision: D3378 Reported by: bde@ Reviewed by: wblock Approved by: bapt, rodrigc (mentor) Sponsored by: gandi.net Notes: svn path=/head/; revision=286715
| * Describe that bcopy(3) is deprecated and marked as LEGACY inMarcelo Araujo2015-08-121-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | POSIX.1-2001 and removed from the specification in POSIX.1-2008. New softwares shall use memcpy(3) or memmove(3). Differential Revision: D3358 Reviewed by: wblock Approved by: rodrigc Sponsored by: gandi.net Notes: svn path=/head/; revision=286651
* | Update wcscoll forgotten in previous patchBaptiste Daroussin2015-08-091-51/+143
| | | | | | | | Notes: svn path=/projects/collation/; revision=286535
* | Fix typoBaptiste Daroussin2015-08-092-14/+8
| | | | | | | | | | | | | | | | | | Remove useless tests before free() Suggested by: jilles Notes: svn path=/projects/collation/; revision=286493
* | The collate functions within libc have been using version 1 and 1.2 of theBaptiste Daroussin2015-08-073-135/+127
|/ | | | | | | | | | | | | | | | | | | | | | | | | packed LC_COLLATE binary formats. These were generated with the colldef tool, but the new LC_COLLATE files are going to be generated by the new localedef tool using CLDR POSIX files as input. The BSD-flavored version of localedef identifies the format as "BSD 1.0". Any LC_COLLATE file with a different version will simply not be loaded, and all LC* categories will get set to "C" (aka "POSIX") locale. This work is based off of Nexenta's contribution to Illumos. The integration with xlocale is John Marino's work for Dragonfly. The following commits will enable localedef tool, disable the colldef tool, add generated colldef directory, and finally remove colldef from base. The only difference with Dragonfly are: - a few fixes to build with clang - And identification of the flavor as "BSD 1.0" instead of "Dragonfly 4.4" Obtained from: Dragonfly Notes: svn path=/projects/collation/; revision=286430
* strchr(3): Mdoc fixes.Jilles Tjoelker2015-06-041-3/+5
| | | | Notes: svn path=/head/; revision=284001
* memmem(3): empty little string matches the beginning of the big stringEd Maste2015-05-262-11/+17
| | | | | | | | | | | | | | | This function originated in glibc, and this matches their behaviour (and NetBSD, OpenBSD, and musl). An empty big string (arg "l") is handled by the existing l_len < s_len test. Reviewed by: bapt, ngie Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D2657 Notes: svn path=/head/; revision=283584
* Make strlcpy/strlcat slightly easier to read.Pedro F. Giffuni2015-04-062-43/+42
| | | | | | | | | Bring small upstream updates. Obtained from: OpenBSD Notes: svn path=/head/; revision=281135
* Various mdoc fixes and a few EOL whitespace removals.Christian Brueffer2014-12-211-1/+1
| | | | | | | Found with: mandoc -Tlint Notes: svn path=/head/; revision=276006
* Remove duplicated code.Xin LI2014-10-162-22/+1
| | | | | | | Suggested by: jmg Notes: svn path=/head/; revision=273189
* Add MLINK for explicit_bzero(3) and bump .Dd date.Xin LI2014-10-072-1/+2
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=272675
* Add explicit_bzero(3) and its kernel counterpart.Xin LI2014-10-074-2/+45
| | | | | | | | Obtained from: OpenBSD MFC after: 2 weeks Notes: svn path=/head/; revision=272673
* use .Mt to mark up email addresses consistently (part4)Baptiste Daroussin2014-06-233-5/+4
| | | | | | | | PR: 191174 Submitted by: Franco Fichtner <franco at lastsummer.de> Notes: svn path=/head/; revision=267774
* Fix strcasecmp_l() and strncasecmp_l() POSIX 2008 compliance.Pedro F. Giffuni2014-05-301-2/+2
| | | | | | | | | | | | | | | POSIX.1-2008 specifies that those two functions should be declared by including <strings.h>, not <string.h> (the latter only has strcoll_l() and strxfrm_l()): http://pubs.opengroup.org/onlinepubs/9699919799/functions/strcasecmp.html Obtained from: DragonFlyBSD Reviewed by: theraven MFC after: 2 weeks Notes: svn path=/head/; revision=266865
* Emphasis on 'do not' and 'complement' in the strcspn(3)Allan Jude2014-05-271-5/+6
| | | | | | | | | Replace literal parentheses with .Po/.Pc Approved by: wblock (mentor) Notes: svn path=/head/; revision=266725
* Merge strcspn.3 into strspn.3 and clarify the explaination of what they doAllan Jude2014-05-253-98/+37
| | | | | | | | | | Detach strcspn.3 from the build Add strcspn.3 to MLINKS do it will be symlinked to strspn.3 Approved by: eadler (mentor), bcr (mentor) Notes: svn path=/head/; revision=266671
* libc man pages: Remove reference to non-existent FreeBSD SecurityEitan Adler2014-03-072-6/+0
| | | | | | | | | Architecture MFC After: 3 days Notes: svn path=/head/; revision=262890
* Replace use of ${.CURDIR} by ${LIBC_SRCTOP} and define ${LIBC_SRCTOP}Marcel Moolenaar2014-03-041-4/+4
| | | | | | | | | | | | | | if not already defined. This allows building libc from outside of lib/libc using a reach-over makefile. A typical use-case is to build a standard ILP32 version and a COMPAT32 version in a single iteration by building the COMPAT32 version using a reach-over makefile. Obtained from: Juniper Networks, Inc. Notes: svn path=/head/; revision=262722
* Fix typo: site_t -> size_tEitan Adler2013-11-101-1/+1
| | | | | | | Obtained From: DragonflyBSD (1ac92c8c857a15dc010924c5f066da404e568640) Notes: svn path=/head/; revision=257909
* Fix .Dd after r257646.Glen Barber2013-11-051-1/+1
| | | | | | | | DST affects the day by one hour, but the number of days in the week stay the same. Notes: svn path=/head/; revision=257720
* Use OpenBSD's revamped description of strlcpy and strlcat.Eitan Adler2013-11-041-68/+63
| | | | | | | | | | | | | | This explanation is supposed to be simpler and better. In particular "comparing it to the snprintf API provides lots of value, since it raises the bar on understanding, so that programmers/auditors will a better job calling all 3 of these functions." Requested by: deraadt@cvs.openbsd.org Obtained From: OpenBSD Reviewed by: cperciva Notes: svn path=/head/; revision=257646
* libc: Always use our own copy of sys_errlist and sys_nerr (.so only).Jilles Tjoelker2013-08-311-3/+5
| | | | | | | | | | | | | | | | | | This ensures strerror() and friends continue to work correctly even if a (non-PIE) executable linked against an older libc imports sys_errlist (which causes sys_errlist to refer to the executable's copy with a size fixed when that executable was linked). The executable's use of sys_errlist remains broken because it uses the current value of sys_nerr and may access past the bounds of the array. Different from the message "Using sys_errlist from executables is not ABI-stable" on freebsd-arch, this change does not affect the static library. There seems no reason to prevent overriding the error messages in the static library. Notes: svn path=/head/; revision=255108
* Renumber clauses to reduce diffs to other versionsEd Maste2013-05-2873-73/+73
| | | | | | | | 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
* Create a symlink from strchrnul.3 to strchr.3.Niclas Zeising2013-03-061-1/+2
| | | | | | | | | This was forgotten in the initial commit of strchrnul() Approved by: theraven Notes: svn path=/head/; revision=247899
* Add strchrnul(), a GNU function similar to strchr(), except that it returnsNiclas Zeising2013-02-134-5/+81
| | | | | | | | | | a pointer to the end of the string, rather than NULL, if the character was not found. Approved by: theraven Notes: svn path=/head/; revision=246766
* clarify the wording for 'first' and 'last'Eitan Adler2012-09-301-5/+4
| | | | | | | | Approved by: wblock MFC after: 3 days Notes: svn path=/head/; revision=241062