[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Bugfix: "Okay, I just shut down like you told me. Now let ...
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv12255/src/or
Modified Files:
routerlist.c routerparse.c
Log Message:
Bugfix: "Okay, I just shut down like you told me. Now let me verify your signature." Also fix error message when running over-new version.
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -d -r1.112 -r1.113
--- routerlist.c 4 Aug 2004 01:25:21 -0000 1.112
+++ routerlist.c 4 Aug 2004 02:35:06 -0000 1.113
@@ -610,7 +610,6 @@
crypto_pk_env_t *pkey)
{
routerlist_t *new_list = NULL;
- check_software_version_against_directory(s, options.IgnoreVersion);
if (router_parse_routerlist_from_directory(s, &new_list, pkey)) {
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.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- routerparse.c 4 Aug 2004 01:17:21 -0000 1.20
+++ routerparse.c 4 Aug 2004 02:35:06 -0000 1.21
@@ -16,6 +16,8 @@
/****************************************************************************/
+extern or_options_t options; /* command-line and config-file options */
+
/** Enumeration of possible token types. The ones starting with K_
* correspond to directory 'keywords'. _UNRECOGNIZED is for an
* unrecognized keyword; _ERR is an error in the tokenizing process,
@@ -229,10 +231,13 @@
* ignored.) */
/* static */ int is_obsolete_version(const char *myversion,
const char *versionlist) {
+ const char *vl;
char *version, *comma, *cp;
tor_version_t mine, other;
int found_newer = 0, r;
+ vl = versionlist;
+
log_fn(LOG_DEBUG,"checking '%s' in '%s'.", myversion, versionlist);
if (tor_version_parse(myversion, &mine)) {
@@ -241,9 +246,8 @@
}
for(;;) {
- comma = strchr(versionlist, ',');
- version = tor_strndup(versionlist,
- comma?(comma-versionlist):strlen(versionlist));
+ comma = strchr(vl, ',');
+ version = tor_strndup(vl, comma?(comma-vl):strlen(vl));
cp = version;
while (isspace(*cp))
++cp;
@@ -263,7 +267,7 @@
}
tor_free(version);
if (comma)
- versionlist = comma+1;
+ vl = comma+1;
else
break;
}
@@ -324,7 +328,7 @@
smartlist_t *good_nickname_list = NULL;
time_t published_on;
int i, r;
- const char *end;
+ const char *end, *cp;
smartlist_t *tokens = NULL;
if (router_get_dir_hash(str, digest)) {
@@ -333,6 +337,37 @@
}
log_fn(LOG_DEBUG,"Received directory hashes to %s",hex_str(digest,4));
+ /* Check signature first, before we try to tokenize. */
+ cp = str;
+ while (cp && (end = strstr(cp+1, "\ndirectory-signature")))
+ cp = end;
+ if (cp == str || !cp) {
+ log_fn(LOG_WARN, "No signature found on directory."); goto err;
+ }
+ ++cp;
+ tokens = smartlist_create();
+ if (tokenize_string(cp,strchr(cp,'\0'),tokens,1)) {
+ log_fn(LOG_WARN, "Error tokenizing directory signature"); goto err;
+ }
+ if (smartlist_len(tokens) != 1) {
+ log_fn(LOG_WARN, "Unexpected number of tokens in signature"); goto err;
+ }
+ if (smartlist_len(tokens) != 1 ||
+ (!(tok=smartlist_get(tokens,0))) || /* always succeeds */
+ (tok->tp != K_DIRECTORY_SIGNATURE)) {
+ log_fn(LOG_WARN,"Expected a single directory signature"); goto err;
+ }
+ if (check_directory_signature(digest, smartlist_get(tokens,0), pkey)<0) {
+ goto err;
+ }
+ SMARTLIST_FOREACH(tokens, directory_token_t *, tok, token_free(tok));
+ smartlist_free(tokens);
+ tokens = NULL;
+
+ /* Now that we know the signature is okay, check the version. */
+ check_software_version_against_directory(str, options.IgnoreVersion);
+
+ /* Now try to parse the first part of the directory. */
if ((end = strstr(str,"\nrouter "))) {
++end;
} else if ((end = strstr(str, "\ndirectory-signature"))) {
@@ -404,20 +439,7 @@
SMARTLIST_FOREACH(tokens, directory_token_t *, tok, token_free(tok));
smartlist_free(tokens);
-
- tokens = smartlist_create();
- if (tokenize_string(str,str+strlen(str),tokens,1)<0) {
- log_fn(LOG_WARN, "Error tokenizing signature"); goto err;
- }
-
- if (smartlist_len(tokens) != 1 ||
- (!(tok=smartlist_get(tokens,0))) || /* always succeeds */
- (tok->tp != K_DIRECTORY_SIGNATURE)) {
- log_fn(LOG_WARN,"Expected a single directory signature"); goto err;
- }
- if (check_directory_signature(digest, smartlist_get(tokens,0), pkey)<0) {
- goto err;
- }
+ tokens = NULL;
/* Determine if my routerinfo is considered verified. */
{