Skip to content

Commit

Permalink
Fixed #57 secure-compare length issue
Browse files Browse the repository at this point in the history
  • Loading branch information
weavejester committed May 15, 2013
1 parent cf17e62 commit be1eac9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ring-core/src/ring/middleware/session/cookie.clj
Expand Up @@ -83,10 +83,10 @@
(str (codec/base64-encode data) "--" (hmac key data))))

(defn- secure-compare [^String a ^String b]
(if (and a b (= (.length a) (.length b)))
(zero? (reduce bit-or
(map bit-xor (.getBytes a) (.getBytes b))))
false))
(let [a (map int a), b (map int b)]
(if (and a b (= (count a) (count b)))
(zero? (reduce bit-or (map bit-xor a b)))
false)))

(defn- unseal
"Retrieve a sealed Clojure data structure from a string"
Expand Down

0 comments on commit be1eac9

Please sign in to comment.