[or-cvs] r12021: Fix segfault in init_keys() (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Thu Oct 18 14:23:20 UTC 2007


Author: nickm
Date: 2007-10-18 10:23:19 -0400 (Thu, 18 Oct 2007)
New Revision: 12021

Modified:
   tor/trunk/
   tor/trunk/src/or/router.c
Log:
 r15913 at catbus:  nickm | 2007-10-18 10:22:19 -0400
 Fix segfault in init_keys()



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r15913] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c	2007-10-18 14:19:56 UTC (rev 12020)
+++ tor/trunk/src/or/router.c	2007-10-18 14:23:19 UTC (rev 12021)
@@ -510,15 +510,16 @@
   /* 5. Dump fingerprint to 'fingerprint' */
   keydir = get_datadir_fname("fingerprint");
   log_info(LD_GENERAL,"Dumping fingerprint to \"%s\"...",keydir);
-  tor_free(keydir);
   if (crypto_pk_get_fingerprint(get_identity_key(), fingerprint, 1)<0) {
     log_err(LD_GENERAL,"Error computing fingerprint");
+    tor_free(keydir);
     return -1;
   }
   tor_assert(strlen(options->Nickname) <= MAX_NICKNAME_LEN);
   if (tor_snprintf(fingerprint_line, sizeof(fingerprint_line),
                    "%s %s\n",options->Nickname, fingerprint) < 0) {
     log_err(LD_GENERAL,"Error writing fingerprint line");
+    tor_free(keydir);
     return -1;
   }
   /* Check whether we need to write the fingerprint file. */
@@ -528,10 +529,12 @@
   if (!cp || strcmp(cp, fingerprint_line)) {
     if (write_str_to_file(keydir, fingerprint_line, 0)) {
       log_err(LD_FS, "Error writing fingerprint line to file");
+      tor_free(keydir);
       return -1;
     }
   }
   tor_free(cp);
+  tor_free(keydir);
 
   log(LOG_NOTICE, LD_GENERAL,
       "Your Tor server's identity key fingerprint is '%s %s'",



More information about the tor-commits mailing list