]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r325066:
authorpfg <pfg@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Sat, 4 Nov 2017 14:45:36 +0000 (14:45 +0000)
committerpfg <pfg@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Sat, 4 Nov 2017 14:45:36 +0000 (14:45 +0000)
commitd149fa4fd4e507b3bd3c2510157e1c6864c8f2d2
tree7c18840d75041cfbb2fe797c65865fe588a181bc
parent237fd3e2a9ebb1791cd1fb2600d06f936c07bce2
MFC r325066:
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

git-svn-id: svn://svn.freebsd.org/base/stable/10@325394 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
lib/libc/regex/regcomp.c