summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrofl0r <retnyg@gmx.net>2011-08-10 01:44:47 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-08-10 15:41:36 +0200
commit7949f2cdc6eb1ac0f076e06e6a3fa47540a9b870 (patch)
treed4c3d901817add5a0fd9f3c139411110fd3e6020
parent2f878736427f5fd846f8ebb0c834e6a65bf8a638 (diff)
downloadlibssh-7949f2cdc6eb1ac0f076e06e6a3fa47540a9b870.tar.gz
libssh-7949f2cdc6eb1ac0f076e06e6a3fa47540a9b870.tar.xz
libssh-7949f2cdc6eb1ac0f076e06e6a3fa47540a9b870.zip
session: Fix an infinite loop in the termination callback.
This happened due to the use of the buggy and obsolete timeout funtions.
-rw-r--r--src/session.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/session.c b/src/session.c
index 589fa5b..37c9fd1 100644
--- a/src/session.c
+++ b/src/session.c
@@ -492,23 +492,17 @@ int ssh_handle_packets(ssh_session session, int timeout) {
* @return SSH_OK on success, SSH_ERROR otherwise.
*/
int ssh_handle_packets_termination(ssh_session session, int timeout,
- ssh_termination_function fct, void *user){
- int ret = SSH_ERROR;
- struct ssh_timestamp ts;
- ssh_timestamp_init(&ts);
-
- while(!fct(user)){
- ret = ssh_handle_packets(session, timeout);
- if(ret == SSH_ERROR)
- return SSH_ERROR;
- if(fct(user)) {
- return SSH_OK;
- } else if (ssh_timeout_elapsed(&ts, timeout)) {
- return SSH_AGAIN;
- }
- timeout = ssh_timeout_update(&ts,timeout);
- }
- return ret;
+ ssh_termination_function fct, void *user){
+ int ret = SSH_OK;
+
+ while(!fct(user)){
+ ret = ssh_handle_packets(session, timeout);
+ if(ret == SSH_ERROR || ret == SSH_AGAIN)
+ return ret;
+ if(fct(user))
+ return SSH_OK;
+ }
+ return ret;
}
/**