Skip to content

Commit 76e971e

Browse files
committed
Dup the arguments to string compare so we can use force_encoding.
1 parent 095cf91 commit 76e971e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

actionpack/lib/action_controller/session/cookie_store.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ def clear_old_cookie_value
168168
if "foo".respond_to?(:force_encoding)
169169
# constant-time comparison algorithm to prevent timing attacks
170170
def secure_compare(a, b)
171-
a = a.force_encoding(Encoding::BINARY)
172-
b = b.force_encoding(Encoding::BINARY)
171+
a = a.dup.force_encoding(Encoding::BINARY)
172+
b = b.dup.force_encoding(Encoding::BINARY)
173173

174174
if a.length == b.length
175175
result = 0

0 commit comments

Comments
 (0)