[or-cvs] Only check versions against downloaded directories, not cac...
Nick Mathewson
nickm at seul.org
Sun Oct 3 02:37:54 UTC 2004
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv22595/src/or
Modified Files:
directory.c dirserv.c or.h routerlist.c routerparse.c test.c
Log Message:
Only check versions against downloaded directories, not cached directories.
Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/src/or/directory.c,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -d -r1.136 -r1.137
--- directory.c 1 Oct 2004 04:45:14 -0000 1.136
+++ directory.c 3 Oct 2004 02:37:51 -0000 1.137
@@ -445,7 +445,7 @@
tor_free(body); tor_free(headers);
return -1;
}
- if(router_load_routerlist_from_directory(body, NULL) < 0){
+ if(router_load_routerlist_from_directory(body, NULL, 1) < 0){
log_fn(LOG_WARN,"I failed to parse the directory I fetched from %s:%d. Ignoring.", conn->address, conn->port);
} else {
log_fn(LOG_INFO,"updated routers.");
Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- dirserv.c 1 Oct 2004 21:02:12 -0000 1.87
+++ dirserv.c 3 Oct 2004 02:37:51 -0000 1.88
@@ -742,7 +742,7 @@
* necessary, but safe is better than sorry. */
new_directory = tor_strdup(the_directory);
/* use a new copy of the dir, since get_dir_from_string scribbles on it */
- if (router_load_routerlist_from_directory(new_directory, get_identity_key())) {
+ if (router_load_routerlist_from_directory(new_directory, get_identity_key(), 1)) {
log_fn(LOG_ERR, "We just generated a directory we can't parse. Dying.");
tor_cleanup();
exit(0);
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.422
retrieving revision 1.423
diff -u -d -r1.422 -r1.423
--- or.h 28 Sep 2004 23:27:41 -0000 1.422
+++ or.h 3 Oct 2004 02:37:51 -0000 1.423
@@ -1420,7 +1420,8 @@
void routerlist_remove_old_routers(int age);
int router_load_routerlist_from_file(char *routerfile, int trusted);
int router_load_routerlist_from_string(const char *s, int trusted);
-int router_load_routerlist_from_directory(const char *s,crypto_pk_env_t *pkey);
+int router_load_routerlist_from_directory(const char *s,crypto_pk_env_t *pkey,
+ int check_version);
int router_compare_addr_to_exit_policy(uint32_t addr, uint16_t port,
struct exit_policy_t *policy);
#define ADDR_POLICY_ACCEPTED 0
@@ -1455,7 +1456,8 @@
time_t published);
int router_parse_routerlist_from_directory(const char *s,
routerlist_t **dest,
- crypto_pk_env_t *pkey);
+ crypto_pk_env_t *pkey,
+ int check_version);
running_routers_t *router_parse_runningrouters(const char *str);
routerinfo_t *router_parse_entry_from_string(const char *s, const char *end);
int router_add_exit_policy_from_string(routerinfo_t *router, const char *s);
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -d -r1.144 -r1.145
--- routerlist.c 29 Sep 2004 06:52:35 -0000 1.144
+++ routerlist.c 3 Oct 2004 02:37:51 -0000 1.145
@@ -65,7 +65,7 @@
s = read_file_to_str(filename,0);
if (s) {
log_fn(LOG_INFO, "Loading cached directory from %s", filename);
- if (router_load_routerlist_from_directory(s, NULL) < 0) {
+ if (router_load_routerlist_from_directory(s, NULL, 0) < 0) {
log_fn(LOG_WARN, "Cached directory '%s' was unparseable; ignoring.", filename);
}
if(routerlist->published_on > time(NULL) - OLD_MIN_ONION_KEY_LIFETIME/2) {
@@ -793,10 +793,12 @@
* signed directory <b>s</b>. If pkey is provided, check the signature against
* pkey; else check against the pkey of the signing directory server. */
int router_load_routerlist_from_directory(const char *s,
- crypto_pk_env_t *pkey)
+ crypto_pk_env_t *pkey,
+ int check_version)
{
routerlist_t *new_list = NULL;
- if (router_parse_routerlist_from_directory(s, &new_list, pkey)) {
+ if (router_parse_routerlist_from_directory(s, &new_list, pkey,
+ check_version)) {
log_fn(LOG_WARN, "Couldn't parse directory.");
return -1;
}
Index: routerparse.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerparse.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- routerparse.c 29 Sep 2004 06:52:36 -0000 1.43
+++ routerparse.c 3 Oct 2004 02:37:52 -0000 1.44
@@ -285,7 +285,8 @@
int /* Should be static; exposed for unit tests */
router_parse_routerlist_from_directory(const char *str,
routerlist_t **dest,
- crypto_pk_env_t *pkey)
+ crypto_pk_env_t *pkey,
+ int check_version)
{
directory_token_t *tok;
char digest[DIGEST_LEN];
@@ -335,7 +336,8 @@
tokens = NULL;
/* Now that we know the signature is okay, check the version. */
- check_software_version_against_directory(str, options.IgnoreVersion);
+ if (check_version)
+ check_software_version_against_directory(str, options.IgnoreVersion);
/* Now try to parse the first part of the directory. */
if ((end = strstr(str,"\nrouter "))) {
Index: test.c
===================================================================
RCS file: /home/or/cvsroot/src/or/test.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- test.c 28 Sep 2004 21:14:40 -0000 1.116
+++ test.c 3 Oct 2004 02:37:52 -0000 1.117
@@ -968,7 +968,7 @@
options.Nickname = "DirServer";
test_assert(!dirserv_dump_directory_to_string(buf,8192,pk3));
cp = buf;
- test_assert(!router_parse_routerlist_from_directory(buf, &dir1, pk3));
+ test_assert(!router_parse_routerlist_from_directory(buf, &dir1, pk3, 1));
test_eq(2, smartlist_len(dir1->routers));
dirserv_free_fingerprint_list();
More information about the tor-commits
mailing list