[or-cvs] more cleanup

Roger Dingledine arma at seul.org
Wed Apr 16 23:22:07 UTC 2003


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/home/arma/work/onion/cvs/src/common

Modified Files:
	crypto.c util.c 
Log Message:
more cleanup


Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- crypto.c	16 Apr 2003 15:24:09 -0000	1.13
+++ crypto.c	16 Apr 2003 23:22:05 -0000	1.14
@@ -599,8 +599,8 @@
   
   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 @@
 
   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;
   }

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- util.c	16 Apr 2003 17:04:57 -0000	1.1
+++ util.c	16 Apr 2003 23:22:05 -0000	1.2
@@ -3,6 +3,7 @@
 /* $Id$ */
 
 #include <stdlib.h>
+#include <limits.h>
 #include "util.h"
 #include "log.h"
 
@@ -21,6 +22,7 @@
 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 @@
     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) {



More information about the tor-commits mailing list