[or-cvs] save and validate TorVersion in the state file.

arma at seul.org arma at seul.org
Mon Jan 2 04:14:54 UTC 2006


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

Modified Files:
	config.c 
Log Message:
save and validate TorVersion in the state file.


Index: config.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.472
retrieving revision 1.473
diff -u -p -d -r1.472 -r1.473
--- config.c	31 Dec 2005 08:16:07 -0000	1.472
+++ config.c	2 Jan 2006 04:14:52 -0000	1.473
@@ -385,7 +385,7 @@ static config_format_t state_format = {
 static or_options_t *global_options = NULL;
 /** Name of most recently read torrc file. */
 static char *torrc_fname = NULL;
-/** Persistant serialized state. */
+/** Persistent serialized state. */
 static or_state_t *global_state = NULL;
 /** DOCDOC */
 static addr_policy_t *reachable_addr_policy = NULL;
@@ -3526,8 +3526,13 @@ static int
 or_state_validate(or_state_t *old_state, or_state_t *state)
 {
   const char *err;
+  tor_version_t v;
   if (entry_nodes_parse_state(state, 0, &err)<0) {
-    warn(LD_GENERAL, "Unable to parse helper nodes: %s", err);
+    warn(LD_GENERAL, "Unable to parse entry nodes: %s", err);
+    return -1;
+  }
+  if (tor_version_parse(state->TorVersion, &v)) {
+    warn(LD_GENERAL, "Unable to parse Tor version '%s'", state->TorVersion);
     return -1;
   }
   return 0;
@@ -3617,6 +3622,8 @@ or_state_save(void)
   size_t len;
   char *fname;
 
+  tor_assert(global_state);
+
   entry_nodes_update_state(global_state);
   rep_hist_update_state(global_state);
 
@@ -3624,6 +3631,8 @@ or_state_save(void)
     return 0;
 
   global_state->LastWritten = time(NULL);
+  tor_free(global_state->TorVersion);
+  global_state->TorVersion = tor_strdup("Tor " VERSION);
   state = config_dump(&state_format, global_state, 0);
   len = strlen(state)+128;
   contents = tor_malloc(len);



More information about the tor-commits mailing list