[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] distinguish between "well-formed and rejected" and "not well



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

Modified Files:
	directory.c dirserv.c 
Log Message:
distinguish between "well-formed and rejected" and "not well
formed", when parsing server descriptors.


Index: directory.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.204
retrieving revision 1.205
diff -u -d -r1.204 -r1.205
--- directory.c	29 Jan 2005 11:16:23 -0000	1.204
+++ directory.c	29 Jan 2005 11:23:34 -0000	1.205
@@ -984,6 +984,7 @@
     const char *msg;
     cp = body;
     switch (dirserv_add_descriptor(&cp, &msg)) {
+      case -2:
       case -1:
         /* malformed descriptor, or something wrong */
         write_http_status_line(conn, 400, msg?msg:"Malformed or unacceptable server descriptor");

Index: dirserv.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.138
retrieving revision 1.139
diff -u -d -r1.138 -r1.139
--- dirserv.c	29 Jan 2005 11:16:23 -0000	1.138
+++ dirserv.c	29 Jan 2005 11:23:34 -0000	1.139
@@ -312,8 +312,9 @@
  * to NULL.
  *
  * Return 1 if descriptor is well-formed and accepted;
- * 0 if well-formed and server is unapproved;
- * -1 if not well-formed or other parsing error.
+ * 0 if well-formed and server is unapproved but accepted;
+ * -1 if well-formed but rejected;
+ * -2 if not well-formed.
  */
 int
 dirserv_add_descriptor(const char **desc, const char **msg)
@@ -335,7 +336,7 @@
   start = strstr(*desc, "router ");
   if (!start) {
     log_fn(LOG_WARN, "no 'router' line found. This is not a descriptor.");
-    return -1;
+    return -2;
   }
   if ((end = strstr(start+6, "\nrouter "))) {
     ++end; /* Include NL. */
@@ -493,7 +494,8 @@
     cp = strstr(cp, "\nrouter ");
     if (!cp) break;
     ++cp;
-    if (dirserv_add_descriptor(&cp,&m) < 0) {
+    if (dirserv_add_descriptor(&cp,&m) < -1) {
+      /* only fail if parsing failed; keep going if simply rejected */
       return -1;
     }
     --cp; /*Back up to newline.*/