freebsd-dev/lib/libc
Miod Vallat d36b5dbe28 libc: regex: rework unsafe pointer arithmetic
regcomp.c uses the "start + count < end" idiom to check that there are
"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.

PR:		252403
2021-01-08 13:58:35 -06:00
..
aarch64 Fix initial exec TLS mode for dynamically loaded shared objects. 2019-03-29 17:52:57 +00:00
amd64 amd64: sync up libc memcmp with the kernel version (r357309) 2020-01-30 19:57:05 +00:00
arm arm/ffs.S: remove stale comment. 2019-12-28 02:11:41 +00:00
capability Fix a few mandoc issues 2020-10-09 19:12:44 +00:00
compat-43 Adjust history, info source from v1's manuals 2019-09-04 13:44:46 +00:00
db Remove the SYMVER build option. 2020-04-30 22:08:40 +00:00
gdtoa Remove sparc64 specific parts of libc. 2020-02-26 18:55:09 +00:00
gen tcgetwinsize(3): provide man page 2021-01-02 04:43:32 +02:00
gmon mcount: tidy up ANSIfication 2018-10-20 22:39:35 +00:00
i386 remove obsolete i386 MD memchr implementation 2019-09-25 16:49:22 +00:00
iconv Remove the SYMVER build option. 2020-04-30 22:08:40 +00:00
include Add eventfd(3) wrappers to libc. 2020-12-27 12:57:26 +02:00
inet libc: fix cases of undefined behavior. 2018-08-07 15:24:19 +00:00
isc SPDX: more ISC-related files. 2017-12-08 17:52:53 +00:00
locale libc: Fix most issues reported by mandoc 2020-12-19 14:54:28 +00:00
md
mips mips: fix some mcount nits 2019-09-02 01:55:55 +00:00
nameser Bounds check again after advancing cp, otherwise we have a possible 2019-09-05 19:35:30 +00:00
net libc: Fix most issues reported by mandoc 2020-12-19 14:54:28 +00:00
nls Implement strerror_l(). 2020-12-16 09:02:09 +00:00
posix1e Drop "All rights reserved" from all my stuff. This includes 2020-10-28 13:46:11 +00:00
powerpc Add CFI start/end proc directives to arm64, i386, and ppc 2020-12-05 00:33:28 +00:00
powerpc64 Add CFI start/end proc directives to arm64, i386, and ppc 2020-12-05 00:33:28 +00:00
powerpcspe [PowerPC] Implement VDSO timebase access on powerpc* 2020-09-08 03:00:31 +00:00
quad Add casts and L suffixes to libc quad support, to work around various 2020-02-17 20:14:59 +00:00
regex libc: regex: rework unsafe pointer arithmetic 2021-01-08 13:58:35 -06:00
resolv Rather than using the legacy IP struct fields in the union for the 2019-06-04 20:53:35 +00:00
riscv libc: Provide sub fp(s|g)etmask() implementations for RISC-V 2020-08-03 12:48:51 +00:00
rpc Fix -Wvoid-pointer-to-enum-cast warnings. 2020-04-15 18:15:58 +00:00
secure Remove the SYMVER build option. 2020-04-30 22:08:40 +00:00
softfloat Add implementations for clog(3), clogf(3), and clog(3). 2018-05-13 09:54:34 +00:00
stdio tmpnam(3): Also mention tmpfile in the ENVIRONMENT section 2020-08-07 16:20:07 +00:00
stdlib libc: Fix most issues reported by mandoc 2020-12-19 14:54:28 +00:00
stdtime strptime: make %k and %l specifiers match their description in 2018-11-03 23:37:13 +00:00
string strerror.3: Fix whitespace issue introduced in r368714 2020-12-18 22:10:17 +00:00
sys aio_fsync(2): Support O_DSYNC. 2021-01-08 13:15:56 +13:00
tests Rename NO_WERROR -> MK_WERROR=no 2021-01-07 09:31:03 +00:00
uuid
x86 libc: Fix most issues reported by mandoc 2020-12-19 14:54:28 +00:00
xdr typo: s/impelmentation/implementation/. 2020-02-07 15:14:29 +00:00
yp Increase the size of the send and receive buffers for YP client rpc 2019-09-16 06:42:01 +00:00
libc_nossp.ldscript
libc.ldscript
Makefile [PowerPC64LE] Use a shared LIBC_ARCH for powerpc64le. 2020-09-23 00:21:51 +00:00
Makefile.depend Update Makefile.depend files 2019-12-11 17:37:53 +00:00
Makefile.depend.options Update libssp paths in various Makefile.depend* files 2020-01-06 18:15:55 +00:00
Versions.def Create namespace for the symbols added during 13-CURRENT cycle. 2018-11-12 19:12:14 +00:00