From a98643c1b5a39764204fcf6835a8b2bee670581d Mon Sep 17 00:00:00 2001 From: Karsten Loesing Date: Tue, 11 Aug 2009 17:33:58 +0200 Subject: [PATCH] Fix possible segmentation fault on directory authorities. The more verbose logs that were added in ee58153 also include a string that might not have been initialized. This can lead to segfaults, e.g., when setting up private Tor networks. Initialize this string with NULL. --- ChangeLog | 2 ++ src/or/dirserv.c | 7 ++++--- src/or/router.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 994ff4c7b3..d64423426e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,8 @@ Changes in version 0.2.1.20 - 2009-??-?? o Minor bugfixes: - Fix a signed/unsigned compile warning in 0.2.1.19. + - Fix possible segmentation fault on directory authorities. Bugfix on + 0.2.1.14-rc. Changes in version 0.2.1.19 - 2009-07-28 diff --git a/src/or/dirserv.c b/src/or/dirserv.c index a64a01bb80..349e383ab5 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -652,8 +652,8 @@ dirserv_add_multiple_descriptors(const char *desc, uint8_t purpose, /** Examine the parsed server descriptor in ri and maybe insert it into * the list of server descriptors. Set *msg to a message that should be - * passed back to the origin of this descriptor. Use source to produce - * better log messages. + * passed back to the origin of this descriptor, or NULL if there is no such + * message. Use source to produce better log messages. * * Return the status of the operation * @@ -667,6 +667,7 @@ dirserv_add_descriptor(routerinfo_t *ri, const char **msg, const char *source) routerinfo_t *ri_old; char *desc, *nickname; size_t desclen = 0; + *msg = NULL; /* If it's too big, refuse it now. Otherwise we'll cache it all over the * network and it'll clog everything up. */ @@ -718,7 +719,7 @@ dirserv_add_descriptor(routerinfo_t *ri, const char **msg, const char *source) control_event_or_authdir_new_descriptor("REJECTED", desc, desclen, *msg); log_info(LD_DIRSERV, "Did not add descriptor from '%s' (source: %s): %s.", - nickname, source, *msg); + nickname, source, *msg ? *msg : "(no message)"); } else { smartlist_t *changed; control_event_or_authdir_new_descriptor("ACCEPTED", desc, desclen, *msg); diff --git a/src/or/router.c b/src/or/router.c index 859a1e805a..f0a1e40743 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -544,7 +544,7 @@ init_keys(void) /* Must be called after keys are initialized. */ mydesc = router_get_my_descriptor(); if (authdir_mode(options)) { - const char *m; + const char *m = NULL; routerinfo_t *ri; /* We need to add our own fingerprint so it gets recognized. */ if (dirserv_add_own_fingerprint(options->Nickname, get_identity_key())) {