From 20eb836f4e763b8a55602b753c98e10647ad58de Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 11 Mar 2015 12:16:18 +0100 Subject: [PATCH] wait_socket: wrong use of difftime() With reversed arguments it would always return a negative value... Bug: https://github.com/bagder/libssh2/issues/1 --- src/session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/session.c b/src/session.c index c253c66e..9e9343f6 100644 --- a/src/session.c +++ b/src/session.c @@ -1,5 +1,5 @@ /* Copyright (c) 2004-2007 Sara Golemon - * Copyright (c) 2009-2011 by Daniel Stenberg + * Copyright (c) 2009-2015 by Daniel Stenberg * Copyright (c) 2010 Simon Josefsson * All rights reserved. * @@ -601,7 +601,7 @@ int _libssh2_wait_socket(LIBSSH2_SESSION *session, time_t start_time) (seconds_to_next == 0 || seconds_to_next > session->api_timeout)) { time_t now = time (NULL); - elapsed_ms = (long)(1000*difftime(start_time, now)); + elapsed_ms = (long)(1000*difftime(now, start_time)); if (elapsed_ms > session->api_timeout) { session->err_code = LIBSSH2_ERROR_TIMEOUT; return LIBSSH2_ERROR_TIMEOUT;