diff options
author | Roger Dingledine <arma@torproject.org> | 2003-04-16 23:22:05 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2003-04-16 23:22:05 +0000 |
commit | fe1aba7f15405193e2359e4364b221c157f11a43 (patch) | |
tree | 0b4ff616170c703075174d9230e833c2722138a9 /src | |
parent | f39ca8a3aa6f40562f359ebb9413b0fe8d15a44b (diff) | |
download | tor-fe1aba7f15405193e2359e4364b221c157f11a43.tar tor-fe1aba7f15405193e2359e4364b221c157f11a43.tar.gz |
more cleanup
svn:r242
Diffstat (limited to 'src')
-rw-r--r-- | src/common/crypto.c | 8 | ||||
-rw-r--r-- | src/common/util.c | 9 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index 626e2c48e..177ae7949 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -599,8 +599,8 @@ int crypto_cipher_encrypt_init_cipher(crypto_cipher_env_t *env) if (crypto_cipher_evp_cipher(env->type, 1)) { RETURN_SSL_OUTCOME(EVP_EncryptInit((EVP_CIPHER_CTX *)env->aux, - crypto_cipher_evp_cipher(env->type, 1), - env->key, env->iv)); + crypto_cipher_evp_cipher(env->type, 1), + env->key, env->iv)); } else { return -1; } @@ -612,8 +612,8 @@ int crypto_cipher_decrypt_init_cipher(crypto_cipher_env_t *env) if (crypto_cipher_evp_cipher(env->type, 0)) { RETURN_SSL_OUTCOME(EVP_EncryptInit((EVP_CIPHER_CTX *)env->aux, - crypto_cipher_evp_cipher(env->type, 0), - env->key, env->iv)); + crypto_cipher_evp_cipher(env->type, 0), + env->key, env->iv)); } else { return -1; } diff --git a/src/common/util.c b/src/common/util.c index c448fbe89..743df0bbb 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -3,6 +3,7 @@ /* $Id$ */ #include <stdlib.h> +#include <limits.h> #include "util.h" #include "log.h" @@ -21,6 +22,7 @@ my_gettimeofday(struct timeval *timeval) long tv_udiff(struct timeval *start, struct timeval *end) { + long udiff; long secdiff = end->tv_sec - start->tv_sec; if (secdiff+1 > LONG_MAX/1000000) { log(LOG_NOTICE, "tv_udiff(): comparing times too far apart."); @@ -30,7 +32,12 @@ tv_udiff(struct timeval *start, struct timeval *end) end->tv_sec--; end->tv_usec += 1000000L; } - return secdiff*1000000L + (end->tv_usec - start->tv_usec); + udiff = secdiff*1000000L + (end->tv_usec - start->tv_usec); + if(udiff < 0) { + log(LOG_NOTICE, "tv_udiff(): start is after end. Returning 0."); + return 0; + } + return udiff; } int tv_cmp(struct timeval *a, struct timeval *b) { |