[tor-commits] [snowflake/master] Use chunk.byteLength as appropriate for ArrayBuffers.

dcf at torproject.org dcf at torproject.org
Thu Dec 20 04:44:49 UTC 2018


commit ab34f8e889e9b516f55dc255a8dd125a46725021
Author: David Fifield <david at bamsoftware.com>
Date:   Tue Dec 4 17:11:29 2018 -0700

    Use chunk.byteLength as appropriate for ArrayBuffers.
    
    Without this, running with non-dummy rate limiter (e.g. ?ratelimit=1000)
    would try to add undefined to a number resulting in NaN.
---
 proxy/proxypair.coffee | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/proxy/proxypair.coffee b/proxy/proxypair.coffee
index 4f401b0..d3340ed 100644
--- a/proxy/proxypair.coffee
+++ b/proxy/proxypair.coffee
@@ -171,7 +171,7 @@ class ProxyPair
          @relay.bufferedAmount < @MAX_BUFFER &&
          @c2rSchedule.length > 0
         chunk = @c2rSchedule.shift()
-        @rateLimit.update chunk.length
+        @rateLimit.update chunk.byteLength
         @relay.send chunk
         busy = true
       # websocket --> WebRTC
@@ -179,7 +179,7 @@ class ProxyPair
          @client.bufferedAmount < @MAX_BUFFER &&
          @r2cSchedule.length > 0
         chunk = @r2cSchedule.shift()
-        @rateLimit.update chunk.length
+        @rateLimit.update chunk.byteLength
         @client.send chunk
         busy = true
 





More information about the tor-commits mailing list