diff options
author | Roger Dingledine <arma@torproject.org> | 2005-05-18 03:52:07 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2005-05-18 03:52:07 +0000 |
commit | 0fa1890e0efa5123cbd6c7684677c1500eb575b6 (patch) | |
tree | dbee35ef19868ec005cd7af01fa10ae5b600460f /src | |
parent | fe78aac02701a118e49e5a23707e5b3d4ad55182 (diff) | |
download | tor-0fa1890e0efa5123cbd6c7684677c1500eb575b6.tar.gz tor-0fa1890e0efa5123cbd6c7684677c1500eb575b6.zip |
fix the assumption that uninitialized variables are 0
clean up router_load_single_router() more
svn:r4266
Diffstat (limited to 'src')
-rw-r--r-- | src/or/control.c | 2 | ||||
-rw-r--r-- | src/or/routerlist.c | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/or/control.c b/src/or/control.c index 41bc5d1782..42db20098d 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -827,7 +827,7 @@ static int handle_control_postdescriptor(connection_t *conn, uint32_t len, const char *body) { - const char *msg; + const char *msg=NULL; switch (router_load_single_router(body, &msg)) { case -1: send_control_error(conn,ERR_SYNTAX,msg?msg: "Could not parse descriptor"); diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 6743e15285..44aa8123b4 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -908,21 +908,22 @@ int router_load_single_router(const char *s, const char **msg) { routerinfo_t *ri; + tor_assert(msg); if (!(ri = router_parse_entry_from_string(s, NULL))) { log_fn(LOG_WARN, "Error parsing router descriptor; dropping."); - if (msg) *msg = "Couldn't parse router descriptor"; + *msg = "Couldn't parse router descriptor"; return -1; } if (router_is_me(ri)) { log_fn(LOG_WARN, "Router's identity key matches mine; dropping."); - if (msg) *msg = "Router's identity key matches mine."; + *msg = "Router's identity key matches mine."; routerinfo_free(ri); return 0; } if (router_resolve(ri)<0) { log_fn(LOG_WARN, "Couldn't resolve router address; dropping."); - if (msg) *msg = "Couldn't resolve router address."; + *msg = "Couldn't resolve router address."; routerinfo_free(ri); return 0; } @@ -934,7 +935,7 @@ router_load_single_router(const char *s, const char **msg) } if (router_add_to_routerlist(ri, msg)<0) { log_fn(LOG_WARN, "Couldn't add router to list; dropping."); - if (msg) *msg = "Couldn't add router to list."; + *msg = "Couldn't add router to list."; /* ri is already freed */ return 0; } else { |