1 Star 0 Fork 23

zouzhimin/rubygem-rack_1

forked from src-openEuler/rubygem-rack 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Fix-CVE-2022-44570.patch 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
zouzhimin 提交于 2024-04-08 18:00 . Fix CVE-2022-44570
From f6d4f528f2df1318a6612845db0b59adc7fe8fc1 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <[email protected]>
Date: Tue, 17 Jan 2023 12:04:37 -0800
Subject: [PATCH] Fix ReDoS in Rack::Utils.get_byte_ranges
This commit fixes a ReDoS problem in `get_byte_ranges`. Thanks
@ooooooo_q for the patch!
[CVE-2022-44570]
---
lib/rack/utils.rb | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/rack/utils.rb b/lib/rack/utils.rb
index 34849ded..14d9e17d 100644
--- a/lib/rack/utils.rb
+++ b/lib/rack/utils.rb
@@ -348,17 +348,18 @@ module Rack
return nil unless http_range && http_range =~ /bytes=([^;]+)/
ranges = []
$1.split(/,\s*/).each do |range_spec|
- return nil unless range_spec =~ /(\d*)-(\d*)/
- r0, r1 = $1, $2
- if r0.empty?
- return nil if r1.empty?
+ return nil unless range_spec.include?('-')
+ range = range_spec.split('-')
+ r0, r1 = range[0], range[1]
+ if r0.nil? || r0.empty?
+ return nil if r1.nil?
# suffix-byte-range-spec, represents trailing suffix of file
r0 = size - r1.to_i
r0 = 0 if r0 < 0
r1 = size - 1
else
r0 = r0.to_i
- if r1.empty?
+ if r1.nil?
r1 = size - 1
else
r1 = r1.to_i
--
2.25.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xiangbudaomz/rubygem-rack_1.git
[email protected]:xiangbudaomz/rubygem-rack_1.git
xiangbudaomz
rubygem-rack_1
rubygem-rack_1
master

搜索帮助