Skip to content

Commit

Permalink
0.4.8
Browse files Browse the repository at this point in the history
- Adds a safety precaution that was added in 0.4.6 but was too greedy (#14)
  • Loading branch information
dresende committed Sep 27, 2016
1 parent f88df45 commit caf3f91
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/Client/ReadStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ ReadStream.prototype._transform = function (chunk, encoding, next) {
while (this.pending.length >= 6) {
var pkg_len = this.pending.readUInt16BE(4) + 6;

if (this.pending.length < pkg_len) return next();
if (this.pending.length < 8) return next(); // safety precaution
if (this.pending.length < pkg_len) return next(); // not all data yet

var data = this.pending.slice(8, pkg_len);
var pkg = {
Expand Down
3 changes: 2 additions & 1 deletion lib/Server/ReadStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ ReadStream.prototype._transform = function (chunk, encoding, next) {
while (this.pending.length >= 6) {
var pkg_len = this.pending.readUInt16BE(4) + 6;

if (this.pending.length < pkg_len) return next();
if (this.pending.length < 8) return next(); // safety precaution
if (this.pending.length < pkg_len) return next(); // not all data yet

var data = this.pending.slice(8, pkg_len);
var pkg = {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "modbus-tcp",
"version" : "0.4.7",
"version" : "0.4.8",
"description" : "Modbus TCP/IP",
"main" : "lib/Modbus.js",
"repository" : "http://github.com/dresende/node-modbus-tcp.git",
Expand Down

0 comments on commit caf3f91

Please sign in to comment.