diff node_modules/node-static/lib/node-static.js @ 76:0ae87af84e2f

added oscgroups
author Rob Canning <rob@foo.net>
date Sun, 13 Jul 2014 10:07:41 +0100
parents 333afcfd3f3a
children
line wrap: on
line diff
--- a/node_modules/node-static/lib/node-static.js	Tue Jul 01 08:51:53 2014 +0000
+++ b/node_modules/node-static/lib/node-static.js	Sun Jul 13 10:07:41 2014 +0100
@@ -8,7 +8,7 @@
   , util   = require('./node-static/util');
 
 // Current version
-var version = [0, 7, 2];
+var version = [0, 7, 3];
 
 Server = function (root, options) {
     if (root && (typeof(root) === 'object')) { options = root; root = null }
@@ -299,8 +299,12 @@
                 flags: 'r',
                 mode: 0666
             }).on('data', function (chunk) {
-                chunk.copy(buffer, offset);
-                offset += chunk.length;
+                // Bounds check the incoming chunk and offset, as copying
+                // a buffer from an invalid offset will throw an error and crash
+                if (chunk.length && offset < buffer.length && offset >= 0) {
+                    chunk.copy(buffer, offset);
+                    offset += chunk.length;
+                }
             }).on('close', function () {
                 streamFile(files, offset);
             }).on('error', function (err) {