Comments (3)
Thank you for the report.
I have fixed it in develop branch.
from oniguruma.
It seems this is not fully fixed, a different input (bytes 0x5c, 0xda) still cause an out of bounds. Test code:
#include <oniguruma.h>
int main()
{
regex_t *reg;
unsigned char inp[2] = { '\\', 0xd8 };
onig_new(®, inp, inp + 2, ONIG_OPTION_DEFAULT,
ONIG_ENCODING_UTF8, ONIG_SYNTAX_DEFAULT, 0);
}
ASAN error:
==29231==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffd81832a2 at pc 0x0000004ab6d5 bp 0x7fffd8181ae0 sp 0x7fffd8181290
READ of size 2 at 0x7fffd81832a2 thread T0
#0 0x4ab6d4 in __asan_memcpy (/mnt/ram/oniguruma/a.out+0x4ab6d4)
#1 0x4f276c in onig_strcpy /mnt/ram/oniguruma/src/regparse.c:230:5
#2 0x4f7856 in onig_node_str_cat /mnt/ram/oniguruma/src/regparse.c:1349:7
#3 0x4f8531 in node_new_str /mnt/ram/oniguruma/src/regparse.c:1408:7
#4 0x511fe2 in parse_exp /mnt/ram/oniguruma/src/regparse.c:4911:13
#5 0x51089b in parse_branch /mnt/ram/oniguruma/src/regparse.c:5205:7
#6 0x50745d in parse_subexp /mnt/ram/oniguruma/src/regparse.c:5242:7
#7 0x4faf0f in parse_regexp /mnt/ram/oniguruma/src/regparse.c:5287:7
#8 0x4fa754 in onig_parse_make_tree /mnt/ram/oniguruma/src/regparse.c:5319:7
#9 0x53e97f in onig_compile /mnt/ram/oniguruma/src/regcomp.c:5279:7
#10 0x54ee52 in onig_new /mnt/ram/oniguruma/src/regcomp.c:5518:7
#11 0x4f21dc in main (/mnt/ram/oniguruma/a.out+0x4f21dc)
#12 0x7f540f06678f in __libc_start_main /var/tmp/portage/sys-libs/glibc-2.23-r2/work/glibc-2.23/csu/../csu/libc-start.c:289
#13 0x419708 in _start (/mnt/ram/oniguruma/a.out+0x419708)
Address 0x7fffd81832a2 is located in stack of thread T0 at offset 66 in frame
#0 0x4f205f in main (/mnt/ram/oniguruma/a.out+0x4f205f)
This frame has 2 object(s):
[32, 40) 'reg'
[64, 66) 'inp' <== Memory access at offset 66 overflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
(longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow (/mnt/ram/oniguruma/a.out+0x4ab6d4) in __asan_memcpy
Shadow bytes around the buggy address:
0x10007b028600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007b028610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007b028620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007b028630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007b028640: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
=>0x10007b028650: 00 f2 f2 f2[02]f3 f3 f3 00 00 00 00 00 00 00 00
0x10007b028660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007b028670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007b028680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007b028690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007b0286a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Heap right redzone: fb
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack partial redzone: f4
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==29231==ABORTING
from oniguruma.
Thanks again.
I have fixed it in develop branch.
(commit: 873ba2d)
from oniguruma.
Related Issues (20)
- Dynamic library generated failed to support "(?-i)" HOT 3
- oniguruma not able to installed on PPC64le architecture HOT 3
- `.{0,99}` and `.*` behave differently on short input HOT 2
- mbc_enc_len(const UChar* p) to be improved HOT 4
- Does Oniguruma support POSIX collating symbols or equivalence classes? HOT 1
- New version?🤔 HOT 1
- Does "retry-limit-in-match over" mean NOT MATCH? HOT 23
- ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS not working for ^* pattern HOT 1
- Literal escaped braces HOT 2
- what is escape code for `.` (literal dot)? HOT 1
- onig_match() can return wrong results with lookbehind at the end of the string HOT 2
- ONIG_SYNTAX_EMACS doesn't support "shy groups"
- With ONIG_SYNTAX_DEFAULT pattern '(?s)ABC' fails with 'undefined group option'. HOT 12
- Error 'unmatched range specifier in char-class' with hyphen in character class. HOT 1
- typos HOT 1
- :alpha: character class matches "non-letter" unicode characters. HOT 4
- Sample pattern and content to trigger error in onig_search? HOT 2
- Invalid utf8 sequence matches the pattern while it probably should not. HOT 1
- Test files ( 'e' function )
- How do I statically link the library to my project without installing it on my system
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oniguruma.