aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/message_verifier.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/message_verifier.rb b/activesupport/lib/active_support/message_verifier.rb
index 1031662293..6c46b68eaf 100644
--- a/activesupport/lib/active_support/message_verifier.rb
+++ b/activesupport/lib/active_support/message_verifier.rb
@@ -47,11 +47,11 @@ module ActiveSupport
def secure_compare(a, b)
return false unless a.bytesize == b.bytesize
- l = a.unpack "C*"
+ l = a.unpack "C#{a.bytesize}"
- res = true
- b.each_byte { |byte| res = (byte == l.shift) && res }
- res
+ res = 0
+ b.each_byte { |byte| res |= byte ^ l.shift }
+ res == 0
end
def generate_digest(data)