summaryrefslogtreecommitdiffstats
path: root/lib/libc/regex/regcomp.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Make CHIN() Boolean-valued and use this to turn an expression with atb2021-01-031-2/+2
| | | | | | quintuple negation into one with a simple negation. From miod, ok millert
* Remove two now-unused functions; a result of the categories removal.millert2021-01-021-39/+2
| | | | From miod@, OK tb@
* More regular error handling with the REQUIRE macro.millert2020-12-311-5/+4
| | | | | | | Changing it from ((condition) || function call) to an if() wrapped in a do/while is easier to read and more stylistically consistent. The seterr() function no longer needs to return a value. From miod@, OK tb@
* Remove unused categories in re_guts; they are written to but never read.millert2020-12-311-37/+2
| | | | From miod@, OK tb@
* Strings in struct parse can be const, they are never modified.millert2020-12-311-15/+11
| | | | | Also, the temporary array in nonnewline() can be made static const. From miod@, OK tb@
* regcomp.c uses the "start + count < end" idiom to check that there aretb2020-12-301-13/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | "count" bytes available in an array of char "start" and "end" both point to. This is fine, unless "start + count" goes beyond the last element of the array. In this case, pedantic interpretation of the C standard makes the comparison of such a pointer against "end" undefined, and optimizers from hell will happily remove as much code as possible because of this. An example of this occurs in regcomp.c's bothcases(), which defines bracket[3], sets "next" to "bracket" and "end" to "bracket + 2". Then it invokes p_bracket(), which starts with "if (p->next + 5 < p->end)"... Because bothcases() and p_bracket() are static functions in regcomp.c, there is a real risk of miscompilation if aggressive inlining happens. The following diff rewrites the "start + count < end" constructs into "end - start > count". Assuming "end" and "start" are always pointing in the array (such as "bracket[3]" above), "end - start" is well-defined and can be compared without trouble. As a bonus, MORE2() implies MORE() therefore SEETWO() can be simplified a bit. from miod, ok millert
* cclasses[] multis field is always an empty string. Remove it and codetb2020-12-301-60/+1
| | | | | | dealing with it. This code was incomplete anyway. from miod, ok millert
* Constify the strings in cnames[]. No functional change.tb2020-12-301-2/+2
| | | | from miod, ok millert
* Do some easy .data -> .rodata/.data.rel.ro conversionsguenther2020-10-131-5/+5
| | | | ok millert@ deraadt@
* Fix typo in last commit.millert2019-02-051-2/+2
|
* Avoid an out of bounds read when regcomp() is passed a bad expression.millert2019-02-051-1/+5
| | | | | | | | When an invalid regular expression is passed, seterr() is called which sets p->error to the appropriate error code and sets p->next and p->end to nuls[]. However, p->next is decremented in the default case in p_ere_exp() and p_simp_re() which makes it point to one byte before nuls[]. From FreeBSD. OK tedu@ deraadt@
* fix oob read; form llvm via Vlad Tsyrklevich; ok millert@otto2017-10-301-3/+3
|
* Clarify code by eliminating unused #define's MUSTSEE, MUSTNOTSEE and inliningkrw2016-12-221-6/+3
| | | | | | MUSTEAT. ok tom@
* Adopt relevant part of NetBSD's r1.7 commit to discard unused results of thekrw2016-12-211-2/+2
| | | | | | | expressions generated by the REQUIRE() macro. Thus eliminating from build output 100 lines or so of gcc complaints about "computed but not used". cluebat & ok tom@
* Delete casts to off_t and size_t that are implied by assignmentsguenther2016-09-211-3/+2
| | | | | | | or prototypes. Ditto for some of the char* and void* casts too. verified no change to instructions on ILP32 (i386) and LP64 (amd64) ok natano@ abluhm@ deraadt@ millert@
* Remove NULL-checks before free() and a few related dead assignments.mmcc2015-12-281-3/+2
| | | | ok and valuable input from millert@
* delete old lint ARGSUSED commentsguenther2015-11-011-3/+1
|
* reallocarray() -- a little tricky to reviewderaadt2014-10-181-3/+3
| | | | ok doug millert
* add \<word\> support to regcomp. prompted by renewed interest from jsgtedu2014-09-081-2/+28
| | | | | | because such support is reportedly common and in somewhat wide use. undocumented for now because we don't endorse this. ok jsg millert
* reallocarray for things which are arrays. ok deraadttedu2014-05-061-8/+8
|
* unsigned char cast for ctype; ok guentherderaadt2013-11-261-2/+2
|
* silence some warnings by adding prototypes, casts, and headers astedu2013-04-171-4/+3
| | | | appropriate. in regex, stop using the struct hack for a fixed size array
* don't handle out-of-mem conditions using compiled out asserts (ugh). Fromotto2011-11-071-9/+10
| | | | netbsd; ok deraadt@
* the posix regex mistake is here to stay. ok deraadttedu2010-11-211-13/+1
|
* if the first call to allocset() fails, the second might deref a NULLotto2008-02-231-1/+4
| | | | | pointer, so add a safety-net. From Gianluigi Tiesi via Torok Edwin. ok chl@ millert@
* add a proper test around allocsetchl2007-10-101-51/+33
| | | | | | | | | | | use a simpler way to allocated memory in allocset, mostly done by replacing malloc/realloc dance, by only one realloc add comments about variables that are not used uninitialized, even if gcc told the contrary another malloc/realloc -> realloc change Work initially started by otto@, and then I joined him ok otto@ ray@
* use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsgderaadt2007-09-021-3/+3
|
* (char)to{upper,lower}()deraadt2006-03-311-3/+3
|
* zap rcsidespie2005-08-051-8/+1
|
* remove useless comments, once used for header file generation and deleteotto2004-11-301-97/+38
| | | | parameter names from prototypes. ok millert@
* ansify and deregister; no change in obj code. ok millert@otto2004-10-171-255/+185
|
* When parsing what follows [, do not allocate memory that is not used,otto2004-05-081-3/+7
| | | | | | also fix a memory leak in error path. ok millert@
* Unbreak handling of non-ASCII chars. Fixes PR 3594. From FreeBSDotto2003-12-071-15/+17
| | | | | | regcmp.c rev 1.13. ok deraadt@
* Remove the advertising clause in the UCB license which Berkeleymillert2003-06-021-6/+2
| | | | rescinded 22 July 1999. Proofed by myself and Theo.
* strcpy/strcat -> strlcpy/strlcattdeval2003-04-051-3/+2
| | | | ok tedu@, hints by deraadt@ and millert@
* Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.millert2002-02-161-38/+38
|
* much greater care for malloc & realloc failures; millert okderaadt2001-11-011-16/+37
|
* realloc repairderaadt1998-08-141-4/+9
|
* Remove dead code and variablestholo1997-04-301-21/+1
|
* - cast usages of *printf() to void since we don't check return valmillert1997-04-281-1/+27
| | | | | | - move an assert to be *before* a strcpy() where it can do some good. - integrate NetBSD fixes for 64-bit machines (NetBSD PR #3450, Ross Harvey) - add lite2 tags
* Remove dead codetholo1996-09-151-64/+3
| | | | | | Remove unused variables Silence some warnings lint(1) is your friend
* Fix RCS idstholo1996-08-191-9/+1
| | | | Make sure everything uses {SYS,}LIBC_SCCS properly
* initial import of NetBSD treederaadt1995-10-181-0/+1704