diff options
author | Roger Dingledine <arma@torproject.org> | 2006-01-02 04:14:52 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2006-01-02 04:14:52 +0000 |
commit | 0bd25f5d43f1f36d5ccdaaf6fa362d2c9ea0f4c4 (patch) | |
tree | 1e46ced4c9b185000d89a4689db43fb399553cfd | |
parent | 2efa0567777fe269b396c08061736648152d20c8 (diff) | |
download | tor-0bd25f5d43f1f36d5ccdaaf6fa362d2c9ea0f4c4.tar.gz tor-0bd25f5d43f1f36d5ccdaaf6fa362d2c9ea0f4c4.zip |
save and validate TorVersion in the state file.
svn:r5694
-rw-r--r-- | src/or/config.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/or/config.c b/src/or/config.c index 09fbdaa689..9bd70b1aa0 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -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); |