[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r10540: Parse networkstatuses (v2, vote, and consensus) after genera (in tor/trunk: . src/or)
Author: nickm
Date: 2007-06-08 15:02:39 -0400 (Fri, 08 Jun 2007)
New Revision: 10540
Modified:
tor/trunk/
tor/trunk/ChangeLog
tor/trunk/src/or/dirserv.c
tor/trunk/src/or/dirvote.c
Log:
r13325@catbus: nickm | 2007-06-08 15:02:37 -0400
Parse networkstatuses (v2, vote, and consensus) after generating them, and fail fast if there is a parse error.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r13325] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog 2007-06-08 18:53:24 UTC (rev 10539)
+++ tor/trunk/ChangeLog 2007-06-08 19:02:39 UTC (rev 10540)
@@ -6,6 +6,10 @@
- tor-gencert creates all files as readable to the file creator only, and
write-protects the authority identity key.
+ o Minor features (directory authority):
+ - Fail quickly and (relatively) harmlessly if we generate a network
+ status document that is somehow malformed.
+
o Deprecated features:
- RedirectExits is now deprecated.
Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c 2007-06-08 18:53:24 UTC (rev 10539)
+++ tor/trunk/src/or/dirserv.c 2007-06-08 19:02:39 UTC (rev 10540)
@@ -1983,10 +1983,19 @@
note_crypto_pk_op(SIGN_DIR);
if (router_append_dirobj_signature(outp,endp-outp,digest,private_key)<0) {
- log_warn(LD_BUG, "Unable to sign router status.");
+ log_warn(LD_BUG, "Unable to sign networkstatus vote.");
goto err;
}
+ {
+ networkstatus_vote_t *v;
+ if (!(v = networkstatus_parse_vote_from_string(status, 1))) {
+ log_err(LD_BUG,"Generated a networkstatus vote we couldn't parse.");
+ goto err;
+ }
+ networkstatus_vote_free(v);
+ }
+
goto done;
err:
@@ -2196,6 +2205,15 @@
}
{
+ networkstatus_t *ns;
+ if (!(ns = networkstatus_parse_from_string(status))) {
+ log_err(LD_BUG,"Generated a networkstatus we couldn't parse.");
+ goto done;
+ }
+ networkstatus_free(ns);
+ }
+
+ {
cached_dir_t **ns_ptr = &the_v2_networkstatus;
if (*ns_ptr)
cached_dir_decref(*ns_ptr);
Modified: tor/trunk/src/or/dirvote.c
===================================================================
--- tor/trunk/src/or/dirvote.c 2007-06-08 18:53:24 UTC (rev 10539)
+++ tor/trunk/src/or/dirvote.c 2007-06-08 19:02:39 UTC (rev 10540)
@@ -623,6 +623,17 @@
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
smartlist_free(chunks);
+ {
+ networkstatus_vote_t *c;
+ if (!(c = networkstatus_parse_vote_from_string(result, 0))) {
+ log_err(LD_BUG,"Generated a networkstatus consensus we couldn't "
+ "parse.");
+ tor_free(result);
+ return NULL;
+ }
+ networkstatus_vote_free(c);
+ }
+
return result;
}