Ticket #63 (closed defect)

Opened 9 years ago

Last modified 8 years ago

second channel creation fails

Reported by: ekatalog Owned by: bagder
Priority: normal Milestone:
Component: API Version:
Keywords: Cc: ekatalog, bagder, thomaspu
Blocked By: Blocks:

Description

As shown in included source code, libssh2 won't create a channel for the second time.

this is what appears in openssh daemon logs:

Feb 26 15:01:34 biuro sshd[3155]: error: buffer_get_string_ret: bad string length 1702663341
Feb 26 15:01:34 biuro sshd[3155]: fatal: buffer_get_string: buffer error
Feb 26 15:01:34 biuro sshd[3155]: pam_unix(sshd:session): session closed for user tefnet

on second channel creation in a program, it would return a NULL channel pointer and give no hint in last_error.

software versions:
libssh2-0.18
openssh-4.7_p1
linux-2.6.17.13

Attachments

libssh2_bug.c (2.1 KB) - added by ekatalog 9 years ago.
Program revealing a bug
1902169.patch (1.5 KB) - added by bagder 8 years ago.
suggested solution to the libssh2_channel_direct_tcpip_ex problem

Download all attachments as: .zip

Change History

Changed 9 years ago by ekatalog

Program revealing a bug

comment:1 Changed 9 years ago by ekatalog

There is a quick fix when running a single channel at a time. Changing libssh2_channel_direct_tcpip_ex() in tunnel.c from:

if (session->direct_state == libssh2_NB_state_idle)

to:

if (session->direct_state == libssh2_NB_state_idle
1)

fixes the problem. Something with direct_stare is messed up. Investigation continues...

comment:2 Changed 9 years ago by ekatalog

I haven't found any other references to direct_state except for this function. It looks like it's not used. Can we safely skip this part of code?

comment:3 Changed 9 years ago by thomaspu

I too have encountered this problem. My quick fix was to always retry channel creation. But this is quite a band-aide approach!

Changed 8 years ago by bagder

suggested solution to the libssh2_channel_direct_tcpip_ex problem

comment:4 Changed 8 years ago by bagder

I just uploaded 1902169.patch to this bug entry. Can you please see if this makes the function run nicer for you?

comment:5 Changed 8 years ago by bagder

No feedback so I've committed my fix and close this entry.

Note: See TracTickets for help on using tickets.