Skip to content

Commit 9f3c265

Browse files
authored
Merge pull request #871 from shubhamshinde360/PA-6283
(PA-6283) Patch stringio in Ruby 2.7 for CVE-2024-27280
2 parents 0014ae7 + 8414d37 commit 9f3c265

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

configs/components/ruby-2.7.8.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
pkg.apply_patch "#{base}/regexp_use_after_free.patch"
4242

4343
pkg.apply_patch "#{base}/uri-redos-cve-2023-36617.patch"
44+
pkg.apply_patch "#{base}/stringio_cve-2024-27280.patch"
4445

4546
if platform.is_cross_compiled?
4647
unless platform.is_macos?
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Backport of:
2+
3+
From c58c5f54f1eab99665ea6a161d29ff6a7490afc8 Mon Sep 17 00:00:00 2001
4+
From: Nobuyoshi Nakada <[email protected]>
5+
Date: Tue, 16 Nov 2021 17:39:32 +0900
6+
Subject: [PATCH] [ruby/stringio] Fix expanding size at ungetc/ungetbyte
7+
8+
https://github.com/ruby/stringio/commit/a35268a3ac
9+
---
10+
ext/stringio/stringio.c | 2 +-
11+
test/stringio/test_stringio.rb | 25 +++++++++++++++++++++----
12+
2 files changed, 22 insertions(+), 5 deletions(-)
13+
14+
--- a/ext/stringio/stringio.c
15+
+++ b/ext/stringio/stringio.c
16+
@@ -983,7 +983,7 @@ strio_unget_bytes(struct StringIO *ptr,
17+
len = RSTRING_LEN(str);
18+
rest = pos - len;
19+
if (cl > pos) {
20+
- long ex = (rest < 0 ? cl-pos : cl+rest);
21+
+ long ex = cl - (rest < 0 ? pos : len);
22+
rb_str_modify_expand(str, ex);
23+
rb_str_set_len(str, len + ex);
24+
s = RSTRING_PTR(str);

0 commit comments

Comments
 (0)