summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/or/dirserv.c56
-rw-r--r--src/rust/tor_util/include.am2
-rw-r--r--src/test/test_consdiff.c16
-rw-r--r--src/test/test_crypto_slow.c3
-rwxr-xr-xsrc/test/test_rust.sh2
5 files changed, 57 insertions, 22 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 4954471c6a..468fdbd488 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -676,8 +676,8 @@ dirserv_add_descriptor(routerinfo_t *ri, const char **msg, const char *source)
control_event_or_authdir_new_descriptor("REJECTED",
ri->cache_info.signed_descriptor_body,
desclen, *msg);
- routerinfo_free(ri);
- return ROUTER_AUTHDIR_REJECTS;
+ r = ROUTER_AUTHDIR_REJECTS;
+ goto fail;
}
/* Check whether this descriptor is semantically identical to the last one
@@ -697,8 +697,8 @@ dirserv_add_descriptor(routerinfo_t *ri, const char **msg, const char *source)
control_event_or_authdir_new_descriptor("DROPPED",
ri->cache_info.signed_descriptor_body,
desclen, *msg);
- routerinfo_free(ri);
- return ROUTER_IS_ALREADY_KNOWN;
+ r = ROUTER_IS_ALREADY_KNOWN;
+ goto fail;
}
/* Do keypinning again ... this time, to add the pin if appropriate */
@@ -721,8 +721,8 @@ dirserv_add_descriptor(routerinfo_t *ri, const char **msg, const char *source)
"its key did not match an older RSA/Ed25519 keypair",
router_describe(ri), source);
*msg = "Looks like your keypair does not match its older value.";
- routerinfo_free(ri);
- return ROUTER_AUTHDIR_REJECTS;
+ r = ROUTER_AUTHDIR_REJECTS;
+ goto fail;
}
/* Make a copy of desc, since router_add_to_routerlist might free
@@ -760,6 +760,20 @@ dirserv_add_descriptor(routerinfo_t *ri, const char **msg, const char *source)
tor_free(desc);
tor_free(nickname);
return r;
+ fail:
+ {
+ const char *desc_digest = ri->cache_info.signed_descriptor_digest;
+ download_status_t *dls =
+ router_get_dl_status_by_descriptor_digest(desc_digest);
+ if (dls) {
+ log_info(LD_GENERAL, "Marking router with descriptor %s as rejected, "
+ "and therefore undownloadable",
+ hex_str(desc_digest, DIGEST_LEN));
+ download_status_mark_impossible(dls);
+ }
+ routerinfo_free(ri);
+ }
+ return r;
}
/** As dirserv_add_descriptor, but for an extrainfo_t <b>ei</b>. */
@@ -768,6 +782,7 @@ dirserv_add_extrainfo(extrainfo_t *ei, const char **msg)
{
routerinfo_t *ri;
int r;
+ was_router_added_t rv;
tor_assert(msg);
*msg = NULL;
@@ -776,8 +791,8 @@ dirserv_add_extrainfo(extrainfo_t *ei, const char **msg)
ri = router_get_mutable_by_digest(ei->cache_info.identity_digest);
if (!ri) {
*msg = "No corresponding router descriptor for extra-info descriptor";
- extrainfo_free(ei);
- return ROUTER_BAD_EI;
+ rv = ROUTER_BAD_EI;
+ goto fail;
}
/* If it's too big, refuse it now. Otherwise we'll cache it all over the
@@ -789,17 +804,34 @@ dirserv_add_extrainfo(extrainfo_t *ei, const char **msg)
(int)ei->cache_info.signed_descriptor_len,
MAX_EXTRAINFO_UPLOAD_SIZE);
*msg = "Extrainfo document was too large";
- extrainfo_free(ei);
- return ROUTER_BAD_EI;
+ rv = ROUTER_BAD_EI;
+ goto fail;
}
if ((r = routerinfo_incompatible_with_extrainfo(ri->identity_pkey, ei,
&ri->cache_info, msg))) {
- extrainfo_free(ei);
- return r < 0 ? ROUTER_IS_ALREADY_KNOWN : ROUTER_BAD_EI;
+ if (r<0) {
+ extrainfo_free(ei);
+ return ROUTER_IS_ALREADY_KNOWN;
+ }
+ rv = ROUTER_BAD_EI;
+ goto fail;
}
router_add_extrainfo_to_routerlist(ei, msg, 0, 0);
return ROUTER_ADDED_SUCCESSFULLY;
+ fail:
+ {
+ const char *d = ei->cache_info.signed_descriptor_digest;
+ signed_descriptor_t *sd = router_get_by_extrainfo_digest((char*)d);
+ if (sd) {
+ log_info(LD_GENERAL, "Marking extrainfo with descriptor %s as "
+ "rejected, and therefore undownloadable",
+ hex_str((char*)d,DIGEST_LEN));
+ download_status_mark_impossible(&sd->ei_dl_status);
+ }
+ extrainfo_free(ei);
+ }
+ return rv;
}
/** Remove all descriptors whose nicknames or fingerprints no longer
diff --git a/src/rust/tor_util/include.am b/src/rust/tor_util/include.am
index 17a755fe09..f0cd63920c 100644
--- a/src/rust/tor_util/include.am
+++ b/src/rust/tor_util/include.am
@@ -7,7 +7,7 @@ EXTRA_DIST +=\
src/rust/target/release/libtor_util.a: FORCE
( cd "$(abs_top_srcdir)/src/rust/tor_util" ; \
CARGO_TARGET_DIR="$(abs_top_builddir)/src/rust/target" \
- HOME="$(abs_top_builddir)/src/rust" \
+ CARGO_HOME="$(abs_top_builddir)/src/rust" \
$(CARGO) build --release --quiet $(CARGO_ONLINE) )
FORCE:
diff --git a/src/test/test_consdiff.c b/src/test/test_consdiff.c
index 23948d6860..7cf8d6ba2b 100644
--- a/src/test/test_consdiff.c
+++ b/src/test/test_consdiff.c
@@ -415,18 +415,18 @@ test_consdiff_base64cmp(void *arg)
tt_int_op(-1, OP_EQ, base64cmp_wrapper("abcABC/+ ", "abcABC/+a"));
/* Comparisons that would return differently with strcmp(). */
- tt_int_op(-1, OP_EQ, strcmp("/foo", "Afoo"));
- tt_int_op(1, OP_EQ, base64cmp_wrapper("/foo", "Afoo"));
- tt_int_op(1, OP_EQ, strcmp("Afoo", "0foo"));
- tt_int_op(-1, OP_EQ, base64cmp_wrapper("Afoo", "0foo"));
+ tt_int_op(strcmp("/foo", "Afoo"), OP_LT, 0);
+ tt_int_op(base64cmp_wrapper("/foo", "Afoo"), OP_GT, 0);
+ tt_int_op(strcmp("Afoo", "0foo"), OP_GT, 0);
+ tt_int_op(base64cmp_wrapper("Afoo", "0foo"), OP_LT, 0);
/* Comparisons that would return the same as with strcmp(). */
- tt_int_op(1, OP_EQ, strcmp("afoo", "Afoo"));
- tt_int_op(1, OP_EQ, base64cmp_wrapper("afoo", "Afoo"));
+ tt_int_op(strcmp("afoo", "Afoo"), OP_GT, 0);
+ tt_int_op(base64cmp_wrapper("afoo", "Afoo"), OP_GT, 0);
/* Different lengths */
- tt_int_op(-1, OP_EQ, base64cmp_wrapper("afoo", "afooo"));
- tt_int_op(1, OP_EQ, base64cmp_wrapper("afooo", "afoo"));
+ tt_int_op(base64cmp_wrapper("afoo", "afooo"), OP_LT, 0);
+ tt_int_op(base64cmp_wrapper("afooo", "afoo"), OP_GT, 0);
done:
;
diff --git a/src/test/test_crypto_slow.c b/src/test/test_crypto_slow.c
index d6b0a43dd5..6d676ff9b9 100644
--- a/src/test/test_crypto_slow.c
+++ b/src/test/test_crypto_slow.c
@@ -12,8 +12,11 @@
#if defined(HAVE_LIBSCRYPT_H) && defined(HAVE_LIBSCRYPT_SCRYPT)
#define HAVE_LIBSCRYPT
+#include <libscrypt.h>
#endif
+#include <openssl/evp.h>
+
/** Run unit tests for our secret-to-key passphrase hashing functionality. */
static void
test_crypto_s2k_rfc2440(void *arg)
diff --git a/src/test/test_rust.sh b/src/test/test_rust.sh
index 4427c70f13..d559f94ce0 100755
--- a/src/test/test_rust.sh
+++ b/src/test/test_rust.sh
@@ -7,7 +7,7 @@ exitcode=0
for crate in $crates; do
cd "${abs_top_srcdir:-.}/src/rust/${crate}"
- CARGO_TARGET_DIR="${abs_top_builddir}/src/rust/target" HOME="${abs_top_builddir}/src/rust" "${CARGO:-cargo}" test ${CARGO_ONLINE-"--frozen"} || exitcode=1
+ CARGO_TARGET_DIR="${abs_top_builddir}/src/rust/target" CARGO_HOME="${abs_top_builddir}/src/rust" "${CARGO:-cargo}" test ${CARGO_ONLINE-"--frozen"} || exitcode=1
done
exit $exitcode