diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2008-05-26 20:14:59 +0000 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2008-05-26 20:14:59 +0000 |
commit | 41475a2a1f2246010d24183cef871051609ff8e9 (patch) | |
tree | 48a42aa9e3cbd0a5bef75570d40a93fb681cb449 /libssh/channels.c | |
parent | c2f151ab56fb56246ac6ff946190d494e436d7a2 (diff) | |
download | libssh-41475a2a1f2246010d24183cef871051609ff8e9.tar.gz libssh-41475a2a1f2246010d24183cef871051609ff8e9.tar.xz libssh-41475a2a1f2246010d24183cef871051609ff8e9.zip |
workaround for the bug #14
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@162 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/channels.c')
-rw-r--r-- | libssh/channels.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libssh/channels.c b/libssh/channels.c index 12fadbd0..41c71dae 100644 --- a/libssh/channels.c +++ b/libssh/channels.c @@ -766,6 +766,9 @@ int channel_read(CHANNEL *channel, BUFFER *buffer,int bytes,int is_stderr){ BUFFER *stdbuf=NULL; int len; buffer_reinit(buffer); + int maxread=bytes; + if(bytes==0) + maxread=MAX_PACKET_LEN; /* maybe i should always set a buffer to avoid races between channel_default_bufferize and channel_read */ if(is_stderr) stdbuf=channel->stderr_buffer; @@ -778,6 +781,8 @@ int channel_read(CHANNEL *channel, BUFFER *buffer,int bytes,int is_stderr){ return 0; if(channel->remote_eof) break; /* return the resting bytes in buffer */ + if(buffer_get_rest_len(stdbuf)>=maxread) // stop reading when buffer is full enough + break; if(packet_read(channel->session)||packet_translate(channel->session)) return -1; packet_parse(channel->session); |