Skip to content

Commit

Permalink
Merge pull request #11 from pusher/master
Browse files Browse the repository at this point in the history
Deal gracefully with nil parameters in comparison
  • Loading branch information
mloughran committed Mar 6, 2015
2 parents a1fe7d5 + 3d9a0bd commit 50b18ef
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/signature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 50b18ef

Please sign in to comment.