Skip to content

Commit

Permalink
wait_socket: wrong use of difftime()
Browse files Browse the repository at this point in the history
With reversed arguments it would always return a negative value...

Bug: libssh2/libssh2#1
  • Loading branch information
bagder committed Mar 11, 2015
1 parent 6ada234 commit 20eb836
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/session.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (c) 2004-2007 Sara Golemon <[email protected]>
* Copyright (c) 2009-2011 by Daniel Stenberg
* Copyright (c) 2009-2015 by Daniel Stenberg
* Copyright (c) 2010 Simon Josefsson <[email protected]>
* All rights reserved.
*
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 20eb836

Please sign in to comment.