-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
(PA-6283) Patch stringio in Ruby 2.7 for CVE-2024-27280
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Backport of: | ||
|
||
From c58c5f54f1eab99665ea6a161d29ff6a7490afc8 Mon Sep 17 00:00:00 2001 | ||
From: Nobuyoshi Nakada <[email protected]> | ||
Date: Tue, 16 Nov 2021 17:39:32 +0900 | ||
Subject: [PATCH] [ruby/stringio] Fix expanding size at ungetc/ungetbyte | ||
|
||
https://github.com/ruby/stringio/commit/a35268a3ac | ||
--- | ||
ext/stringio/stringio.c | 2 +- | ||
test/stringio/test_stringio.rb | 25 +++++++++++++++++++++---- | ||
2 files changed, 22 insertions(+), 5 deletions(-) | ||
|
||
--- a/ext/stringio/stringio.c | ||
+++ b/ext/stringio/stringio.c | ||
@@ -983,7 +983,7 @@ strio_unget_bytes(struct StringIO *ptr, | ||
len = RSTRING_LEN(str); | ||
rest = pos - len; | ||
if (cl > pos) { | ||
- long ex = (rest < 0 ? cl-pos : cl+rest); | ||
+ long ex = cl - (rest < 0 ? pos : len); | ||
rb_str_modify_expand(str, ex); | ||
rb_str_set_len(str, len + ex); | ||
s = RSTRING_PTR(str); |