spmjs / node-scp2

[MAINTAINER WANTED] A pure javascript scp program based on ssh2.
385 stars 96 forks source link

Error: Offset is out of bounds #3

Closed guo-yu closed 10 years ago

guo-yu commented 10 years ago

看了一下服务器,文件是可以正常上传的,但出现一个没有catch的error如下:

fs.js:457
  binding.read(fd, buffer, offset, length, position, wrapper);
          ^
Error: Offset is out of bounds
    at Object.fs.read (fs.js:457:11)
    at /Library/WebServer/Documents/coder/node_modules/scp2/lib/client.js:192:14
    at iterate (/Library/WebServer/Documents/coder/node_modules/scp2/node_modules/async/lib/async.js:131:13)
    at Object.async.eachSeries (/Library/WebServer/Documents/coder/node_modules/scp2/node_modules/async/lib/async.js:147:9)
    at _write (/Library/WebServer/Documents/coder/node_modules/scp2/lib/client.js:189:15)
    at /Library/WebServer/Documents/coder/node_modules/scp2/lib/client.js:221:11
    at SFTP._parse (/Library/WebServer/Documents/coder/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:978:11)
    at ChannelStream.<anonymous> (/Library/WebServer/Documents/coder/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:49:12)
    at ChannelStream.EventEmitter.emit [as _emit] (events.js:95:17)
    at ChannelStream.emit (/Library/WebServer/Documents/coder/node_modules/scp2/node_modules/ssh2/lib/Channel.js:547:12)

node version: v0.10.12 npm version: 1.2.32 scp2: lastest

markszymik commented 10 years ago

Same problem here

lepture commented 10 years ago

@turingou @markszymik I can't reproduce it.

seti123 commented 10 years ago

Is this the same issue? buffer.js:194 this.parent = new SlowBuffer(this.length); ^ RangeError: length > kMaxLength at new Buffer (buffer.js:194:21)

Nexum commented 10 years ago

I have the exact same problem as seti123.... :(

lepture commented 10 years ago

@Nexum how can I reproduce it?

Nexum commented 10 years ago

I#m trying to do this:

scp2.scp(distInfo.tempFile, {
            host:       serverConf.host,
            username:   serverConf.user,
            path:       serverConf.path + "/" + serverConf.file
        }, function (err) {
            info.success = !err;
            cb(err, info);
        })

the host and user are diffrent from my user and they use key based auth, i also tried adding the publicKey but it didnt change anything.

tempfile is a value like: "/home/nexum/data/foo.conf" and serverConf.path + "/" + serverConf.file will give you: "/home/otheruser/data/bar.conf"

lepture commented 10 years ago

@Nexum I've just updated this repo. Please have a try, and feedback. I am not sure that it fixed this issue.

Nexum commented 10 years ago

I just tried, no change :(

Nexum commented 10 years ago

Here is a full trace for you

[ERROR] 13:02:36 RangeError RangeError: length > kMaxLength at new Buffer (buffer.js:194:21) at Parser.expect (/home/kienzler/public_html/nodejs/ape-rewritemanager/trunk/node_modules/scp2/node_modules/ssh2/lib/Parser.js:645:23) at Parser.execute (/home/kienzler/public_html/nodejs/ape-rewritemanager/trunk/node_modules/scp2/node_modules/ssh2/lib/Parser.js:160:16) at Socket. (/home/kienzler/public_html/nodejs/ape-rewritemanager/trunk/node_modules/scp2/node_modules/ssh2/lib/Connection.js:1332:18) at Socket.EventEmitter.emit (events.js:95:17) at Socket. (_streamreadable.js:710:14) at Socket.EventEmitter.emit (events.js:92:17) at emitReadable (_stream_readable.js:382:10) at emitReadable (_stream_readable.js:378:5) at readableAddChunk (_stream_readable.js:143:7) [RangeError: length > kMaxLength] RangeError: length > kMaxLength at new Buffer (buffer.js:194:21) at Parser.expect (/home/kienzler/public_html/nodejs/ape-rewritemanager/trunk/node_modules/scp2/node_modules/ssh2/lib/Parser.js:645:23) at Parser.execute (/home/kienzler/public_html/nodejs/ape-rewritemanager/trunk/node_modules/scp2/node_modules/ssh2/lib/Parser.js:160:16) at Socket. (/home/kienzler/public_html/nodejs/ape-rewritemanager/trunk/node_modules/scp2/node_modules/ssh2/lib/Connection.js:1332:18) at Socket.EventEmitter.emit (events.js:95:17) at Socket. (_streamreadable.js:710:14) at Socket.EventEmitter.emit (events.js:92:17) at emitReadable (_stream_readable.js:382:10) at emitReadable (_stream_readable.js:378:5) at readableAddChunk (_stream_readable.js:143:7)

lepture commented 10 years ago

@Nexum try to change the value of chunkSize in line 157.

Nexum commented 10 years ago

Hm this function doesnt get called before the error...

lepture commented 10 years ago

@Nexum The log didn't show anything about scp2. Can you debug it and find the buggy source code. Maybe you need to console.log a lot.

tehmoon commented 10 years ago

Yep same here,

I'm on OpenBSD 5.4 GENERIC.MP amd64

lepture commented 10 years ago

@tehmoon even the latest? Show me your log.

tehmoon commented 10 years ago

This is my stack err log :

buffer.js:194 this.parent = new SlowBuffer(this.length); ^ RangeError: length > kMaxLength at new Buffer (buffer.js:194:21) at Parser.expect (/home/moon/work/hybris/deploy/node_modules/ssh2/lib/Parser.js:650:23) at Parser.execute (/home/moon/work/hybris/deploy/node_modules/ssh2/lib/Parser.js:163:16) at Socket. (/home/moon/work/hybris/deploy/node_modules/ssh2/lib/Connection.js:1393:18) at Socket.EventEmitter.emit (events.js:95:17) at Socket. (_streamreadable.js:736:14) at Socket.EventEmitter.emit (events.js:92:17) at emitReadable (_stream_readable.js:408:10) at emitReadable (_stream_readable.js:404:5) at readableAddChunk (_stream_readable.js:165:9)

And this is my code :

for(c = 0 ; hosts[argv.e].length > c; c++) {

var host = hosts[argv.e][c] + hostDomain; var options = { username: "deploy", host : hosts[argv.e][c] + hostDomain, port : 22, password: "*****", path : "~/" };

client.scp(argv.d, options, function (err) { if (err) { console.log(err); } else { console.log('[OK] File transferred for host : '.green + host + "."); hostDone.push(null); }});}

I tried to switch to the low level API but it seems to be very slow compared to the scp binary and it doesn't work with directories :(

Regards,

tehmoon commented 10 years ago

And yes even with the latest version wich is the 0.1.4. I even tried with you ninja version and i got : terminate called after throwing an instance of 'std::bad_alloc'

Regards,

lepture commented 10 years ago

@tehmoon I see. It's buffer error:

RangeError: length > kMaxLength

This is not the same issue, you can open another one.