diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2006-12-12 16:32:34 +0000 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2006-12-12 16:32:34 +0000 |
commit | 4479b4aded35f52a49f20053ed81161037818cb6 (patch) | |
tree | e58259f557474b59270078e060cbe436d442cf55 /libssh | |
parent | 77db3bba379688814c3a3f3a182cd87d91941861 (diff) | |
download | libssh-4479b4aded35f52a49f20053ed81161037818cb6.tar.gz libssh-4479b4aded35f52a49f20053ed81161037818cb6.tar.xz libssh-4479b4aded35f52a49f20053ed81161037818cb6.zip |
norbert's patches + strange typo in packet_nonblocking_flush()
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@97 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh')
-rw-r--r-- | libssh/client.c | 2 | ||||
-rw-r--r-- | libssh/packet.c | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/libssh/client.c b/libssh/client.c index da4636a2..9af4e627 100644 --- a/libssh/client.c +++ b/libssh/client.c @@ -36,7 +36,7 @@ char *ssh_get_banner(SSH_SESSION *session){ char buffer[128]; int i = 0; while (i < 127) { - if(session->fd >=0 && read(session->fd, &buffer[i], 1)<=0){ + if(session->fd <0 || read(session->fd, &buffer[i], 1)<=0){ ssh_set_error(session,SSH_FATAL,"Remote host closed connection"); return NULL; } diff --git a/libssh/packet.c b/libssh/packet.c index 900671dd..61034979 100644 --- a/libssh/packet.c +++ b/libssh/packet.c @@ -101,7 +101,8 @@ static int socket_read(SSH_SESSION *session,int len){ if(r<=0){ ssh_set_error(session,SSH_FATAL, (r==0)?"Connection closed by remote host" : "Error reading socket"); - close(session->fd); + if(session->fd>=0) + close(session->fd); session->fd=-1; session->data_except=1; return SSH_ERROR; @@ -359,8 +360,13 @@ static int packet_nonblocking_flush(SSH_SESSION *session){ int except, can_write; int w; ssh_fd_poll(session,&can_write,&except); /* internally sets data_to_write */ + if(session->fd<0){ + session->alive=0; + ssh_set_error(session,SSH_FATAL,"Writing packet : error on socket (or connection closed): %s",strerror(errno)); + return SSH_ERROR; + } while(session->data_to_write && buffer_get_rest_len(session->out_socket_buffer)>0){ - if(session->fd<0){ + if(session->fd>=0){ w=write(session->fd,buffer_get_rest(session->out_socket_buffer), buffer_get_rest_len(session->out_socket_buffer)); session->data_to_write=0; |