Skip to content

Commit 3bab183

Browse files
author
Daniel Mewes
committed
compare_digest fix (for #5916)
1 parent 5536f21 commit 3bab183

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

net.coffee

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,20 +1063,21 @@ class TcpConnection extends Connection
10631063
pbkdf2_cache[cache_string] = u
10641064
return u
10651065

1066+
# a, b should be strings
10661067
compare_digest = (a, b) ->
10671068
left = undefined
10681069
right = b
10691070
result = undefined
10701071
if a.length is b.length
10711072
left = a
10721073
result = 0
1073-
else
1074+
if a.length != b.length
10741075
left = b
10751076
result = 1
10761077

1077-
len = Math.min(a.length, b.length)
1078+
len = Math.min(left.length, right.length)
10781079
for i in [0...len]
1079-
result |= xor_bytes(a[i],b[i])
1080+
result |= left[i] ^ right[i]
10801081

10811082
return result is 0
10821083

0 commit comments

Comments
 (0)