From 3d9a0bd84de4c1655fecd5ef3cff7bc220f3e7ca Mon Sep 17 00:00:00 2001 From: Michael Pye Date: Wed, 4 Mar 2015 09:39:42 +0000 Subject: [PATCH] Deal gracefully with nil parameters in comparison Regression introduced in a8f9c92 --- lib/signature.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/signature.rb b/lib/signature.rb index 57b5867..19d16da 100644 --- a/lib/signature.rb +++ b/lib/signature.rb @@ -223,6 +223,8 @@ def validate_signature!(token) # Constant time string comparison def identical?(a, b) + return true if a.nil? && b.nil? + return false if a.nil? || b.nil? return false unless a.bytesize == b.bytesize a.bytes.zip(b.bytes).reduce(0) { |memo, (a, b)| memo += a ^ b } == 0 end