Hi,
I encountered a problem recently that I don't understand. libssh2_channel_write_ex seems to have returned more bytes than the requested buflen. After this happened my program crashed, presumably because of a buffer overrun. Am I using this function correctly? Below is a code fragment and output.

i=libssh2_channel_write_ex(ssh_channel, 0, (char *)buff, bytesToSend);
        if(i==bytesToSend) {
            return(0);    // I'm done
        } else if( i>=0 || i==LIBSSH2_ERROR_EAGAIN ) {
            // try again after short rest
            if(i>=0) {
ds_error(INFO1, thisRoutine, "wrote %i/%i bytes to ssh channel, trying 2nd time...", i, bytesToSend);
            } else {
ds_error(INFO1, thisRoutine, "ssh channel is busy, trying 2nd time...");
                i=0;
            }
            .
            .
            .

My log file left the message:
[Wed Sep 11 07:59:41 2013] writeRawPacket: wrote 746/46 bytes to ssh channel, trying 2nd time...

This would indicate that libssh2_channel_write_ex returned a value of 746, but I only requested 46.

Any ideas?
Thanks

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

Reply via email to