Skip to content

Commit 77ed8e8

Browse files
committed
Remove nested quantifier
https://hackerone.com/reports/660822
1 parent 65218b9 commit 77ed8e8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/net/imap/authenticators/digest_md5.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def process(challenge)
1515
@stage = STAGE_TWO
1616
sparams = {}
1717
c = StringScanner.new(challenge)
18-
while c.scan(/(?:\s*,)?\s*(\w+)=("(?:[^\\"]+|\\.)*"|[^,]+)\s*/)
18+
while c.scan(/(?:\s*,)?\s*(\w+)=("(?:[^\\"]|\\.)*"|[^,]+)\s*/)
1919
k, v = c[1], c[2]
2020
if v =~ /^"(.*)"$/
2121
v = $1

test/net/imap/test_imap_authenticators.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,14 @@ def test_digest_md5_authenticator_no_qop
153153
auth.process('Qop=""')
154154
end
155155
end
156+
157+
def test_digest_md5_authenticator_illinear
158+
pre = ->(n) {'qop="a' + ',x'*n}
159+
assert_linear_performance([5, 10, 15, 20], pre: pre) do |challenge|
160+
auth = digest_md5("user", "pass")
161+
assert_raise(Net::IMAP::DataFormatError) do
162+
auth.process(challenge)
163+
end
164+
end
165+
end
156166
end

0 commit comments

Comments
 (0)