From 187f22036b3092ee010ad7a174381c8eb8e5cb21 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Sat, 5 Oct 2013 19:10:03 -0400 Subject: [PATCH] weechat-protocol.js: stricter slicing and type checking --- js/weechat-protocol.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/weechat-protocol.js b/js/weechat-protocol.js index 4104fc3..6fbf703 100644 --- a/js/weechat-protocol.js +++ b/js/weechat-protocol.js @@ -70,6 +70,10 @@ WeeChatProtocol.prototype = { _getType: function() { var t = this._getSlice(3); + if (!t) { + return null; + } + return WeeChatProtocol._uia2s(new Uint8Array(t)); }, @@ -347,6 +351,10 @@ WeeChatProtocol.prototype = { * @return Sliced array */ _getSlice: function(length) { + if (this.dataAt + length > this._data.byteLength) { + return null; + } + var slice = this._data.slice(this._dataAt, this._dataAt + length); this._dataAt += length;