Git Product home page Git Product logo

Comments (3)

kkos avatar kkos commented on May 29, 2024

Thank you for the report.
I have fixed it in develop branch.

from oniguruma.

hannob avatar hannob commented on May 29, 2024

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(&reg, 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.

kkos avatar kkos commented on May 29, 2024

Thanks again.
I have fixed it in develop branch.
(commit: 873ba2d)

from oniguruma.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.