summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hintz <t@thintz.com>2014-10-06 07:19:41 -0700
committerThomas Hintz <t@thintz.com>2014-10-06 07:19:41 -0700
commit9312d6d5ca3fd9bbbcf07e9f93124f5a673b49a3 (patch)
treea5736d7a5b55d3ba89e35a0f22619acfe5b7b288
parentc7c8de32f9363e652755fc5c59d8f0297e933456 (diff)
downloadwebsockets-9312d6d5ca3fd9bbbcf07e9f93124f5a673b49a3.tar.gz
Limit max message size for use with the unmask/utf8 code. Change
default max frame size to match default max message size.
-rw-r--r--websockets.scm12
1 files changed, 9 insertions, 3 deletions
diff --git a/websockets.scm b/websockets.scm
index 1e545e9..8f6c86d 100644
--- a/websockets.scm
+++ b/websockets.scm
@@ -27,7 +27,6 @@
(use srfi-1 srfi-4 spiffy intarweb uri-common base64 simple-sha1 srfi-18
srfi-13 mailbox)
-; TODO make sure all C operations check args to prevent overflows
(foreign-declare "#include \"utf8validator.c\"")
(define-inline (neq? obj1 obj2) (not (eq? obj1 obj2)))
@@ -40,8 +39,13 @@
(define drop-incoming-pings (make-parameter #t))
(define propagate-common-errors (make-parameter #f))
-(define max-frame-size (make-parameter 65536)) ; 64KiB
-(define max-message-size (make-parameter 1048576)) ; 1MiB
+(define max-frame-size (make-parameter 1048576)) ; 1MiB
+(define max-message-size
+ (make-parameter 1048576 ; 1MiB
+ (lambda (v)
+ (if (> v 1073741823) ; max int size for unmask/utf8 check
+ (signal (make-property-condition 'out-of-range))
+ v))))
(define (make-websocket-exception . conditions)
(apply make-composite-condition (append `(,(make-property-condition 'websocket))
@@ -198,6 +202,8 @@
(define-external wsv scheme-pointer payload)
((foreign-lambda* void ()
"
+ if (wslen > UINT_MAX) { return -1; }
+
const unsigned char* maskkey2 = wsmaskkey;
const unsigned int kd = *(unsigned int*)maskkey2;
const unsigned char* __restrict kb = maskkey2;