ruby/prism
Peter Zhu eca3680c27 [ruby/prism] Fix use of uninitialized value when parsing regexp
Parsing the regexp /\A{/ causes uses an uninitialized value because it
tries to parse it as a range quantifier, so it reads the character after
the closing curly bracket. This is using uninitialized values because
prism strings are not null terminated. This can be seen in the Valgrind
output:

    ==834710== Conditional jump or move depends on uninitialised value(s)
    ==834710==    at 0x5DA010: pm_regexp_parse_range_quantifier (regexp.c:163)
    ==834710==    by 0x5DA010: pm_regexp_parse_quantifier (regexp.c:243)
    ==834710==    by 0x5DAD69: pm_regexp_parse_expression (regexp.c:738)
    ==834710==    by 0x5DAD69: pm_regexp_parse_pattern (regexp.c:761)
    ==834710==    by 0x5DAD69: pm_regexp_parse (regexp.c:773)
    ==834710==    by 0x5A2EE7: parse_regular_expression_named_captures (prism.c:20886)
    ==834710==    by 0x5A2EE7: parse_expression_infix (prism.c:21388)
    ==834710==    by 0x5A5FA5: parse_expression (prism.c:21804)
    ==834710==    by 0x5A64F3: parse_statements (prism.c:13858)
    ==834710==    by 0x5A9730: parse_program (prism.c:22011)
    ==834710==    by 0x576F0D: parse_input_success_p (extension.c:1062)
    ==834710==    by 0x576F0D: parse_success_p (extension.c:1084)

This commit adds checks for the end of the string to
pm_regexp_parse_range_quantifier.

https://github.com/ruby/prism/commit/be6cbc23ef
2024-11-12 14:19:46 +00:00
..
templates [ruby/prism] Relocation 2024-10-16 15:56:01 +00:00
util [ruby/prism] Only read from buffer if `size` is greater than 0 2024-10-28 20:38:20 +00:00
api_pack.c [ruby/prism] Fix up minimal build setting 2024-03-25 11:54:20 -04:00
config.yml [ruby/prism] Update rescue node doc 2024-10-10 13:43:58 +00:00
defines.h [ruby/prism] Remove use of __assume to simplify 2024-09-25 16:17:08 +00:00
encoding.c [ruby/prism] Provide options for reducing size 2024-03-20 17:32:03 -04:00
encoding.h [ruby/prism] Provide options for reducing size 2024-03-20 17:32:03 -04:00
extension.c [ruby/prism] Supress string_query function warning 2024-10-13 12:22:58 +00:00
extension.h [PRISM] Sync version update 2024-08-28 15:43:32 -04:00
node.h [ruby/prism] Remove various unused memsize infra 2024-05-24 17:19:34 +00:00
options.c [ruby/prism] Accept version shorthand like 3.4 2024-09-24 13:21:36 +00:00
options.h [ruby/prism] Accept version shorthand like 3.4 2024-09-24 13:21:36 +00:00
pack.c [ruby/prism] Provide options for reducing size 2024-03-20 17:32:03 -04:00
pack.h [ruby/prism] Fix up minimal build setting 2024-03-25 11:54:20 -04:00
parser.h [ruby/prism] Fix up multi target parsing 2024-10-04 16:22:21 +00:00
prettyprint.h [ruby/prism] Fix up minimal build setting 2024-03-25 11:54:20 -04:00
prism.c [ruby/prism] Fix splat after kwsplat 2024-11-08 15:50:54 +00:00
prism.h [ruby/prism] Prism::StringQuery 2024-10-11 19:34:57 +00:00
regexp.c [ruby/prism] Fix use of uninitialized value when parsing regexp 2024-11-12 14:19:46 +00:00
regexp.h [ruby/prism] Properly support parsing regexp in extended mode 2024-07-01 14:42:10 +00:00
static_literals.c [ruby/prism] Remove Debug::static_inspect 2024-05-24 17:19:33 +00:00
static_literals.h [ruby/prism] Remove Debug::static_inspect 2024-05-24 17:19:33 +00:00
version.h [PRISM] Sync version update 2024-08-28 15:43:32 -04:00