[or-cvs] fix the cpuworker circ-had-vanished bug (maybe)

Roger Dingledine arma at seul.org
Sun Sep 14 02:59:19 UTC 2003


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

Modified Files:
	tortls.c util.c util.h 
Log Message:
fix the cpuworker circ-had-vanished bug (maybe)

still several (many) tls-related bugs outstanding.


Index: tortls.c
===================================================================
RCS file: /home/or/cvsroot/src/common/tortls.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- tortls.c	11 Sep 2003 23:26:31 -0000	1.8
+++ tortls.c	14 Sep 2003 02:58:47 -0000	1.9
@@ -421,7 +421,7 @@
   time_t now;
   crypto_pk_env_t *r = NULL;
   if (!(cert = SSL_get_peer_certificate(tls->ssl)))
-    return 0;
+    return NULL;
   
   now = time(NULL);
   if (X509_cmp_time(X509_get_notBefore(cert), &now) > 0)
@@ -453,3 +453,4 @@
     RSA_free(rsa);
   return r;
 }
+

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- util.c	20 Aug 2003 23:05:19 -0000	1.16
+++ util.c	14 Sep 2003 02:58:47 -0000	1.17
@@ -103,6 +103,21 @@
   return count;
 }
 
+/* a wrapper for read(2) that makes sure to read all count bytes.
+ * Only use if fd is a blocking socket. */
+int read_all(int fd, void *buf, size_t count) {
+  int numread = 0;
+  int result;
+
+  while(numread != count) {
+    result = read(fd, buf+numread, count-numread);
+    if(result<=0)
+      return -1;
+    numread += result;
+  }
+  return count;
+}
+
 void set_socket_nonblocking(int socket)
 {
 #ifdef MS_WINDOWS

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- util.h	20 Aug 2003 23:05:19 -0000	1.10
+++ util.h	14 Sep 2003 02:58:47 -0000	1.11
@@ -52,6 +52,7 @@
 int tv_cmp(struct timeval *a, struct timeval *b);
 
 int write_all(int fd, const void *buf, size_t count);
+int read_all(int fd, void *buf, size_t count);
 
 void set_socket_nonblocking(int socket);
 



More information about the tor-commits mailing list