summaryrefslogtreecommitdiff
path: root/encoding.c
diff options
context:
space:
mode:
authorJeremy Evans <[email protected]>2021-08-11 13:50:59 -0700
committerJeremy Evans <[email protected]>2021-10-01 19:50:19 -0900
commitabc0304cb28cb9dcc3476993bc487884c139fd11 (patch)
treea1d1c3551f806222bc07d5d53356cc53368f7fd8 /encoding.c
parentd08721465850a6e6954b43bbfebe2ed5a7256dec (diff)
Avoid race condition in Regexp#match
In certain conditions, Regexp#match could return a MatchData with missing captures. This seems to require at the least, multiple threads calling a method that calls the same block/proc/lambda which calls Regexp#match. The race condition happens because the MatchData is passed from indirectly via the backref, and other threads can modify the backref. Fix the issue by: 1. Not reusing the existing MatchData from the backref, and always allocating a new MatchData. 2. Passing the MatchData directly to the caller using a VALUE*, instead of indirectly through the backref. It's likely that variants of this issue exist for other Regexp methods. Anywhere that MatchData is passed implicitly through the backref is probably vulnerable to this issue. Fixes [Bug #17507]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4734
Diffstat (limited to 'encoding.c')
0 files changed, 0 insertions, 0 deletions