summaryrefslogtreecommitdiff
path: root/lib/libc/regex
Commit message (Collapse)AuthorAgeFilesLines
* MFC r325066:Pedro F. Giffuni2017-11-041-1/+1
| | | | | | | | | | | | | | | | | | | | Fix out-of-bounds read in libc/regex. The bug is an out-of-bounds read detected with address sanitizer that happens when 'sp' in p_b_coll_elems() includes NUL byte[s], e.g. if it's equal to "GS\x00". In that case len will be equal to 4, and the strncmp(cp->name, sp, len) call will succeed when cp->name is "GS" but the cp->name[len] == '\0' comparison will cause the read to go out-of-bounds. Checking the length using strlen() instead eliminates the issue. The bug was found in LLVM with oss-fuzz: https://reviews.llvm.org/D39380 Obtained from: Vlad Tsyrklevich through posting on openbsd-tech Notes: svn path=/stable/10/; revision=325394
* MFC r317707:Brooks Davis2017-05-091-0/+4
| | | | | | | | | | | | | | | | | | | | | | Correct an out-of-bounds read in regcomp when the RE is bad. When passed the invalid regular expression "a**", the error is eventually detected and seterr() is called. It sets p->error appropriatly and p->next and p->end to nuls which is a never used char nuls[10] which is zeros due to .bss initialization. Unfortunatly, p_ere_exp() and p_simp_re() both have fall through cases where they set the error, decrement p->next and access it which means a read from whatever .bss variable comes before nuls. Found with regex_test:repet_multi and CHERI bounds checking. Reviewed by: ngie, pfg, emaste Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D10541 Notes: svn path=/stable/10/; revision=318030
* MFC r312332:Enji Cooper2017-02-041-1/+1
| | | | | | | | Use SRCTOP where possible and use :H to manipulate .CURDIR to get rid of unnecessarily long relative path .PATH values with make Notes: svn path=/stable/10/; revision=313221
* MFC: r302824Andrey A. Chernov2016-07-221-6/+5
| | | | | | | | | | | | | | | | 1) Eliminate possibility to call __*collate_range_cmp() with inclomplete locale (which cause core dump) by removing whole 'table' argument by which it passed. 2) Restore __collate_range_cmp() in __sccl(). 3) Collating [a-z] range in regcomp() works for single byte locales only (we can't do it for other ones). In previous state only first 256 wide chars are considered and all others are just silently dropped from the range. Notes: svn path=/stable/10/; revision=303185
* MFC r300683:Pedro F. Giffuni2016-06-242-24/+50
| | | | | | | | | | | | | | | | | | | | | | | | | libc: regexec(3) adjustment. Change the behavior of when REG_STARTEND is combined with REG_NOTBOL. From the original posting[1]: "Enable the assumption that pmatch[0].rm_so is a continuation offset to a string and allows us to do a proper assessment of the character in regards to it's word position ('^' or '\<'), without risking going into unallocated memory." This change makes us similar to how glibc handles REG_STARTEND | REG_NOTBOL, and is closely related to a soon-to-land fix to sed. Special thanks to Martijn van Duren and Ingo Schwarze for working out some consistent behaviour. Differential Revision: https://reviews.freebsd.org/D6257 Taken from: openbsd-tech 2016-05-24 [1] (Martijn van Duren) Notes: svn path=/stable/10/; revision=302168
* MFC r300378:Pedro F. Giffuni2016-05-291-9/+6
| | | | | | | | | | | | | | | | libc/regex: fix two buffer underruns. Fix some rather complex regex issues found on OpenBSD as part of some ongoing work to fix a sed(1) bug. Curiously the OpenBSD tests don't trigger segfaults on FreeBSD but the bugs were confirmed by running a port of FreeBSD's regex under OpenBSD's malloc. Huge thanks to Ingo for confirming the behavior. Obtained from: OpenBSD (CVS 1.20, 1.21) Notes: svn path=/stable/10/; revision=300963
* MFC r298521;Pedro F. Giffuni2016-04-281-2/+2
| | | | | | | | | | | | | | regex: prevent two improbable signed integer overflows. In matcher() we used an integer to index nsub of type size_t. In print() we used an integer to index nstates of type sopno, typedef'd long. In both cases the indexes never take negative values. Match the types to avoid any error. Notes: svn path=/stable/10/; revision=298726
* MFC r292153:Enji Cooper2015-12-201-1/+1
| | | | | | | | | | | | Add -static to CFLAGS to unbreak the tests by using a libc.a with the xlocale private symbols exposed which aren't exposed publicly via the DSO PR: 191354 Sponsored by: EMC / Isilon Storage Division Notes: svn path=/stable/10/; revision=292481
* MFC r291837:Enji Cooper2015-12-133-4/+6
| | | | | | | | | | | | | split.ih: - Create automatically generated include header for split.c main.c: - Use function definitions from debug.ih and split.ih instead of externs Sponsored by: EMC / Isilon Storage Division Notes: svn path=/stable/10/; revision=292170
* Revert r292168 -- I used the wrong commit message by accidentEnji Cooper2015-12-133-6/+4
| | | | Notes: svn path=/stable/10/; revision=292169
* MFC r276737,r289369,r289376,r289424,r291219,r291382,r291385,r291908:Enji Cooper2015-12-133-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r276737 (by imp): Remove old ioctl use and support, once and for all. r289369 (by emaste): newfs_msdos: rework option parsing to match NetBSD NetBSD split newfs_msdos in two so that they can reuse the file system creation part in makefs. This change is a step on the path of bringing that support to FreeBSD. Reviewed by: kib, pfg Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3905 r289376 (by emaste): newfs_msdos: move mkfs_msdos to separate file for later use in makefs Sponsored by: The FreeBSD Foundation r289424 (by emaste): newfs_msdos: prefer snprintf to sprintf Obtained from: NetBSD Sponsored by: The FreeBSD Foundation r291219 (by emaste): newfs_msdos: rework error handling for eventual use in makefs Return -1 on errors from mkfs_msdos() instead of err()/errx(), to allow different consumers to handle errors as appropriate. Obtained from: NetBSD Sponsored by: The FreeBSD Foundation r291382 (by emaste): mkfs_msdos: sync with NetBSD Add a sanity test and clean up whitespace. Obtained from: NetBSD r291385 (by emaste): Use netbsd usage() implementation in newfs_msdos In r289629 newfs_msdos option descriptions are available in mkfs_msdos.h. Obtained from: NetBSD r291908: Fix leak in mkfs_msdos(..) by initializing img to NULL and free'ing at the end of the function Differential Revision: https://reviews.freebsd.org/D4405 PR: 204943 Reviewed by: emaste, jilles Reported by: David Binderman <dcb314@hotmail.com> Sponsored by: EMC / Isilon Storage Division Notes: svn path=/stable/10/; revision=292168
* MFC r291832,r291833,r291834,r291835,r291836,r291838:Enji Cooper2015-12-133-78/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r291832: Fix -Wformat warnings by using the correct format qualifiers Sponsored by: EMC / Isilon Storage Division r291833: - Use ANSI C function prototypes/definitions instead of K&R style ones - Add a missing return type for main(..) Sponsored by: EMC / Isilon Storage Division r291834: Add missing headers and sort #includes per style(9) Sponsored by: EMC / Isilon Storage Division r291835: Use ANSI C function prototypes/definitions instead of K&R style ones Sponsored by: EMC / Isilon Storage Division r291836: Use `==` instead of `=` in the function comment above split(..) so mkh -p exposes split(..). Sponsored by: EMC / Isilon Storage Division r291838: Fix -Wformat issues and minor whitespace issues in surrounding areas Sponsored by: EMC / Isilon Storage Division Notes: svn path=/stable/10/; revision=292144
* MFC r278739:Xin LI2015-02-171-0/+17
| | | | | | | | | | | Disallow pattern spaces which would cause intermediate calculations to overflow size_t. Obtained from: DragonFly (2841837793bd095a82f477e9c370cfe6cfb3862c dillon) Security: CERT VU#695940 Notes: svn path=/stable/10/; revision=278910
* MFC r275930:Xin LI2015-01-021-1/+3
| | | | | | | | | Plug a memory leak. Obtained from: DragonFlyBSD (commit 5119ece) Notes: svn path=/stable/10/; revision=276548
* MFC r268066:Pedro F. Giffuni2014-08-032-2/+25
| | | | | | | | | | | | | | | | | | | | | | regex(3): Add support for \< and \> word delimiters Solaris and other OSs have support for \< and \> as word delimiters in utilities like sed(1). These are useful to have for general compatiblity with Solaris but should be avoided for portability with other systems, including the traditional BSDs. Bump __FreeBSD_version as this is likely to affect some userland utilities. Reference: https://www.illumos.org/issues/516 PR: bin/153257 Obtained from: Illumos Notes: svn path=/stable/10/; revision=269484
* MFC r265202:Pedro F. Giffuni2014-05-092-7/+1
| | | | | | | | | | | | Remove some unreachable breaks in regex. This is based on a much bigger cleanup done in Illumos. Reference: https://www.illumos.org/issues/2077 Notes: svn path=/stable/10/; revision=265726
* Fix assignment of maximum bounadary.Xin LI2013-03-011-1/+1
| | | | | | | | | Submitted by: Sascha Wildner <saw online de> Obtained from: DragonFly rev fd39c81ba220f7ad6e4dc9b30d45e828cf58a1ad MFC after: 2 weeks Notes: svn path=/head/; revision=247596
* Remove some duplicated copyright notices.David Chisnall2012-03-061-5/+0
| | | | | | | Approved by: dim (mentor) Notes: svn path=/head/; revision=232601
* Implement xlocale APIs from Darwin, mainly for use by libc++. This adds aDavid Chisnall2011-11-201-4/+16
| | | | | | | | | | | | | | | load of _l suffixed versions of various standard library functions that use the global locale, making them take an explicit locale parameter. Also adds support for per-thread locales. This work was funded by the FreeBSD Foundation. Please test any code you have that uses the C standard locale functions! Reviewed by: das (gdtoa changes) Approved by: dim (mentor) Notes: svn path=/head/; revision=227753
* Converting int to wint_t leads to broekn comparison of raw charKevin Lo2011-11-111-8/+8
| | | | | | | | | and encoded wint_t. Spotted by: ache Notes: svn path=/head/; revision=227435
* - Don't handle out-of-memory conditionKevin Lo2011-11-101-20/+21
| | | | | | | | | | - Fix types of function arguments match their declaration Reviewed by: delphij Obtained from: NetBSD Notes: svn path=/head/; revision=227414
* mdoc: drop redundant .Pp and .LP callsUlrich Spörlein2010-10-081-1/+0
| | | | | | | They have no effect when coming in pairs, or before .Bl/.Bd Notes: svn path=/head/; revision=213573
* Fix an off-by-one error in the marking of the O_CH operatorDiomidis Spinellis2009-09-161-1/+1
| | | | | | | | | | following an OOR2 operator. PR: 130504 MFC after: 2 weeks Notes: svn path=/head/; revision=197246
* Add a couple of debugging statements.Diomidis Spinellis2009-09-161-0/+3
| | | | Notes: svn path=/head/; revision=197245
* Add two test cases from PR 130504.Diomidis Spinellis2009-09-151-0/+3
| | | | | | | | | | | | | An additional one coming from http://www.research.att.com/~gsf/testregex/ was not added; at some point the entire AT&T regression test harness should be imported here. But that would also mean commitment to fix the uncovered errors. PR: 130504 Submitted by: Chris Kuklewicz Notes: svn path=/head/; revision=197234
* Add two example regexps: (1) one for matching all the charactersGiorgos Keramidas2008-09-051-0/+8
| | | | | | | | | | | that belong in a character class, and (2) one for matching all the characters *not* in a character class. Submitted by: Mark B, mkbucc at gmail.com MFC after: 3 days Notes: svn path=/head/; revision=182795
* getopt(3) returns -1, not EOF.Kevin Lo2008-02-181-1/+1
| | | | Notes: svn path=/head/; revision=176380
* Diff reduction against other *BSDs: ANSIfy functionXin LI2007-06-114-141/+66
| | | | | | | prototypes. No function changes. Notes: svn path=/head/; revision=170528
* Const'ify and ANSIfy the internal interfaces of regex(3).Xin LI2007-05-251-109/+100
| | | | | | | | This is the final change that makes libc to compile with WERROR on my amd64 crashbox. Notes: svn path=/head/; revision=169982
* Use C comments since we now preprocess these files with CPP.Daniel Eischen2007-04-291-1/+3
| | | | Notes: svn path=/head/; revision=169092
* Test cases for back references.Xin LI2007-03-051-0/+24
| | | | | | | Obtained from: OpenBSD Notes: svn path=/head/; revision=167223
* Only stop evaluation of a back reference if the match length isXin LI2007-03-051-15/+17
| | | | | | | | | zero and the recursion level is too deep. Obtained from: OpenBSD Notes: svn path=/head/; revision=167222
* Avoid infinite recursion on:Xin LI2007-03-051-0/+2
| | | | | | | | | echo "foo foo bar bar bar baz" | sed 's/\([^ ]*\)\( *\1\)*/\1/g' Obtained from: OpenBSD via NetBSD (rev. 1.18) Notes: svn path=/head/; revision=167216
* Per Regents of the University of Calfornia letter, remove advertisingWarner Losh2007-01-099-36/+0
| | | | | | | | | clause. # If I've done so improperly on a file, please let me know. Notes: svn path=/head/; revision=165903
* Add each directory's symbol map file to SYM_MAPS.Daniel Eischen2006-03-131-0/+2
| | | | Notes: svn path=/head/; revision=156613
* Add symbol maps and initial symbol version definitions to libc.Daniel Eischen2006-03-131-0/+8
| | | | | | | Reviewed by: davidxu Notes: svn path=/head/; revision=156608
* Use prototypes for CHIN1() and CHIN().Stefan Farfeleder2005-09-121-6/+2
| | | | Notes: svn path=/head/; revision=150053
* Fix a boundary condition error in slow() and fast() in multibyte locales:Tim J. Robbins2005-08-171-6/+7
| | | | | | | | we must allow the character beginning at "p" to be converted to a wide character for the purposes of EOL processing and word-boundary matching. Notes: svn path=/head/; revision=149180
* Document the fact that word-boundary matching does not workTim J. Robbins2005-08-171-1/+3
| | | | | | | properly in multibyte locales. Notes: svn path=/head/; revision=149179
* Change OUT from -2 to CHAR_MIN-1, making it impossible for it toTim J. Robbins2005-08-131-1/+1
| | | | | | | | | | | | inadvertently match a negative char in the RE being compiled. This fixes compilation of "\376" (as an ERE) and "\376\376" (as a BRE). PR: 84740 MFC after: 1 week Notes: svn path=/head/; revision=149009
* Remove unused file.Xin LI2005-04-251-63/+0
| | | | | | | | | | Confirmed by: tjr [1] [1] PERFORCE CHANGESET 57044: http://perforce.freebsd.org/changeView.cgi?CH=57044 Notes: svn path=/head/; revision=145493
* Expand *n't contractions.Ruslan Ermilov2005-02-131-3/+3
| | | | Notes: svn path=/head/; revision=141846
* Sort sections.Ruslan Ermilov2005-01-201-8/+8
| | | | Notes: svn path=/head/; revision=140505
* Plug memory leak.Diomidis Spinellis2004-12-301-0/+4
| | | | | | | | PR: bin/75656 MFC after: 2 weeks Notes: svn path=/head/; revision=139437
* Fix computation of the 'n' argument to mbrtowc (through XMBRTOWC) to avoidTim J. Robbins2004-11-211-4/+4
| | | | | | | | | | | | | reading past 'stop' in various places when converting multibyte characters. Reading too far caused truncation to not be detected when it should have been, eventually causing regexec() to loop infinitely in with certain combinations of patterns and strings in multibyte locales. PR: 74020 MFC after: 4 weeks Notes: svn path=/head/; revision=137959
* Directly include <runetype.h> for _CurrentRuneLocale, <_ctype.h> doesn'tStefan Farfeleder2004-10-031-0/+1
| | | | | | | include it in all cases. Notes: svn path=/head/; revision=136091
* Fix two problems with REG_ICASE that were introduced with the addition ofTim J. Robbins2004-09-051-13/+10
| | | | | | | | | | | | | | multibyte character support: - In CHadd(), avoid writing past the end of the character set bitmap when the opposite-case counterpart of wide characters with values less than NC have values greater than or equal to NC. - In CHaddtype(), fix a braino that caused alphabetic characters to be added to all character classes! (but only with REG_ICASE) PR: 71367 Notes: svn path=/head/; revision=134802
* Update paths to reg*.c and regex2.h. Add a target to build regex.h.Tim J. Robbins2004-07-191-1/+3
| | | | Notes: svn path=/head/; revision=132390
* Update for removal of cclass.h. Trim some useless targets. Invoke mkhTim J. Robbins2004-07-191-34/+6
| | | | | | | with "sh mkh" so it works if the script is not executable. Notes: svn path=/head/; revision=132389
* Update for recent changes to struct re_guts. Disable printing the contentsTim J. Robbins2004-07-191-38/+5
| | | | | | | of OANYOF sets for the moment. Notes: svn path=/head/; revision=132388