Skip to content

Commit 1befac5

Browse files
(PA-6386) Patch Ruby for CVE-2024-27282
- Patches the ruby 'Use-After-Free' issue for regexp. - Upstream fix commit: ruby/ruby@90b194b
1 parent dd06b4f commit 1befac5

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

configs/components/ruby-2.7.8.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
base = 'resources/patches/ruby_27'
3939
# Patch for https://bugs.ruby-lang.org/issues/14972
4040
pkg.apply_patch "#{base}/net_http_eof_14972_r2.5.patch"
41+
pkg.apply_patch "#{base}/regexp_use_after_free.patch"
4142

4243
pkg.apply_patch "#{base}/uri-redos-cve-2023-36617.patch"
4344

configs/components/ruby-3.2.3.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#########
3838

3939
base = 'resources/patches/ruby_32'
40+
pkg.apply_patch "#{base}/regexp_use_after_free.patch"
4041

4142
if platform.is_cross_compiled?
4243
pkg.apply_patch "#{base}/rbinstall_gem_path.patch"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/regexec.c b/regexec.c
2+
index 73694ab14a..140691ad42 100644
3+
--- a/regexec.c
4+
+++ b/regexec.c
5+
@@ -3449,8 +3449,8 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
6+
CASE(OP_MEMORY_END_PUSH_REC) MOP_IN(OP_MEMORY_END_PUSH_REC);
7+
GET_MEMNUM_INC(mem, p);
8+
STACK_GET_MEM_START(mem, stkp); /* should be before push mem-end. */
9+
- STACK_PUSH_MEM_END(mem, s);
10+
mem_start_stk[mem] = GET_STACK_INDEX(stkp);
11+
+ STACK_PUSH_MEM_END(mem, s);
12+
MOP_OUT;
13+
JUMP;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/regexec.c b/regexec.c
2+
index 73694ab14a..140691ad42 100644
3+
--- a/regexec.c
4+
+++ b/regexec.c
5+
@@ -3449,8 +3449,8 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
6+
CASE(OP_MEMORY_END_PUSH_REC) MOP_IN(OP_MEMORY_END_PUSH_REC);
7+
GET_MEMNUM_INC(mem, p);
8+
STACK_GET_MEM_START(mem, stkp); /* should be before push mem-end. */
9+
- STACK_PUSH_MEM_END(mem, s);
10+
mem_start_stk[mem] = GET_STACK_INDEX(stkp);
11+
+ STACK_PUSH_MEM_END(mem, s);
12+
MOP_OUT;
13+
JUMP;

0 commit comments

Comments
 (0)