aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml29
-rw-r--r--changes/bug277404
-rw-r--r--changes/bug278043
-rw-r--r--changes/bug281153
-rw-r--r--changes/bug282024
-rw-r--r--changes/rust_asan8
-rw-r--r--changes/ticket277512
-rw-r--r--changes/ticket279133
-rw-r--r--configure.ac9
-rw-r--r--link_rust.sh.in10
-rw-r--r--src/feature/dirparse/microdesc_parse.c6
-rw-r--r--src/feature/dirparse/parsecommon.c2
-rw-r--r--src/lib/crypt_ops/crypto_ope.c12
-rw-r--r--src/rust/Cargo.lock1
-rw-r--r--src/rust/Cargo.toml16
-rw-r--r--src/rust/crypto/Cargo.toml1
-rw-r--r--src/rust/external/Cargo.toml6
-rw-r--r--src/rust/external/lib.rs2
-rw-r--r--src/rust/protover/Cargo.toml1
-rw-r--r--src/rust/protover/ffi.rs3
-rw-r--r--src/rust/smartlist/Cargo.toml1
-rw-r--r--src/rust/smartlist/lib.rs9
-rw-r--r--src/rust/tor_allocate/Cargo.toml1
-rw-r--r--src/rust/tor_allocate/lib.rs5
-rw-r--r--src/rust/tor_log/Cargo.toml1
-rw-r--r--src/rust/tor_log/tor_log.rs8
-rw-r--r--src/rust/tor_rust/Cargo.toml2
-rw-r--r--src/rust/tor_util/Cargo.toml1
-rw-r--r--src/test/include.am3
-rw-r--r--src/test/test_protover.c1
-rwxr-xr-xsrc/test/test_rust.sh10
31 files changed, 94 insertions, 73 deletions
diff --git a/.travis.yml b/.travis.yml
index de526fe0f3..b5713d6933 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -33,12 +33,8 @@ env:
## We don't list default variable values, because we set the defaults
## in global (or the default is unset)
-
- ## We turn off hardening for Rust builds, because they are incompatible,
- ## and it's going to take a while for them to be fixed. See:
- ## https:/trac.torproject.org/projects/tor/ticket/25386
- ## https:/trac.torproject.org/projects/tor/ticket/26398
## TOR_RUST_DEPENDENCIES is spelt RUST_DEPENDENCIES in 0.3.2
- - RUST_OPTIONS="--enable-rust" TOR_RUST_DEPENDENCIES=true HARDENING_OPTIONS=""
+ - RUST_OPTIONS="--enable-rust" TOR_RUST_DEPENDENCIES=true
matrix:
## include creates builds with gcc, linux, sudo: false
@@ -51,12 +47,15 @@ matrix:
# - env: HARDENING_OPTIONS=""
## We check asciidoc with distcheck, to make sure we remove doc products
- env: DISTCHECK="yes" ASCIIDOC_OPTIONS=""
+ # We clone our stem repo and run `make test-stem`
+ - env: TEST_STEM="yes"
## Check rust online with distcheck, to make sure we remove rust products
- ## But without hardening (see above)
- - env: DISTCHECK="yes" RUST_OPTIONS="--enable-rust --enable-cargo-online-mode" HARDENING_OPTIONS=""
+ - env: DISTCHECK="yes" RUST_OPTIONS="--enable-rust --enable-cargo-online-mode"
## Check disable module dirauth with and without rust
- - env: MODULES_OPTIONS="--disable-module-dirauth" RUST_OPTIONS="--enable-rust" TOR_RUST_DEPENDENCIES=true HARDENING_OPTIONS=""
+ - env: MODULES_OPTIONS="--disable-module-dirauth" RUST_OPTIONS="--enable-rust" TOR_RUST_DEPENDENCIES=true
- env: MODULES_OPTIONS="--disable-module-dirauth"
+ ## Check NSS
+ - env: NSS_OPTIONS="--enable-nss"
## Uncomment to allow the build to report success (with non-required
## sub-builds continuing to run) if all required sub-builds have
@@ -121,6 +120,7 @@ addons:
## Optional dependencies
- libcap-dev
- liblzma-dev
+ - libnss3-dev
- libscrypt-dev
- libseccomp-dev
## zstd doesn't exist in Ubuntu Trusty
@@ -176,11 +176,12 @@ install:
- if [[ "$ASCIIDOC_OPTIONS" == "" ]] && [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export XML_CATALOG_FILES="/usr/local/etc/xml/catalog"; fi
## If we're using Rust, download rustup
- if [[ "$RUST_OPTIONS" != "" ]]; then curl -Ssf -o rustup.sh https://sh.rustup.rs; fi
- ## Install the stable channels of rustc and cargo and setup our toolchain environment
- - if [[ "$RUST_OPTIONS" != "" ]]; then sh rustup.sh -y --default-toolchain stable; fi
+ ## Install the nightly channels of rustc and cargo and setup our toolchain environment
+ - if [[ "$RUST_OPTIONS" != "" ]]; then sh rustup.sh -y --default-toolchain nightly; fi
- if [[ "$RUST_OPTIONS" != "" ]]; then source $HOME/.cargo/env; fi
## If we're testing rust builds in offline-mode, then set up our vendored dependencies
- if [[ "$TOR_RUST_DEPENDENCIES" == "true" ]]; then export TOR_RUST_DEPENDENCIES=$PWD/src/ext/rust/crates; fi
+ - if [[ "$TEST_STEM" != "" ]]; then git clone --depth 1 https://github.com/torproject/stem.git ; export STEM_SOURCE_DIR=`pwd`/stem; fi
##
## Finally, list installed package versions
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then dpkg-query --show; fi
@@ -192,15 +193,17 @@ install:
- if [[ "$RUST_OPTIONS" != "" ]]; then rustup --version; fi
- if [[ "$RUST_OPTIONS" != "" ]]; then rustc --version; fi
- if [[ "$RUST_OPTIONS" != "" ]]; then cargo --version; fi
+ - if [[ "$TEST_STEM" != "" ]]; then pushd stem; python -c "from stem import stem; print(stem.__version__);"; git log -1; popd; fi
script:
- ./autogen.sh
- - CONFIGURE_FLAGS="$ASCIIDOC_OPTIONS $COVERAGE_OPTIONS $HARDENING_OPTIONS $MODULES_OPTIONS $OPENSSL_OPTIONS $RUST_OPTIONS --enable-fatal-warnings --disable-silent-rules"
+ - CONFIGURE_FLAGS="$ASCIIDOC_OPTIONS $COVERAGE_OPTIONS $HARDENING_OPTIONS $MODULES_OPTIONS $NSS_OPTIONS $OPENSSL_OPTIONS $RUST_OPTIONS --enable-fatal-warnings --disable-silent-rules"
- echo "Configure flags are $CONFIGURE_FLAGS"
- ./configure $CONFIGURE_FLAGS
## We run `make check` because that's what https://jenkins.torproject.org does.
- - if [[ "$DISTCHECK" == "" ]]; then make check; fi
- - if [[ "$DISTCHECK" != "" ]]; then make distcheck DISTCHECK_CONFIGURE_FLAGS="$CONFIGURE_FLAGS"; fi
+ - if [[ "$DISTCHECK" == "" && "$TEST_STEM" == "" ]]; then make check; fi
+ - if [[ "$TEST_STEM" != "" ]]; then make src/app/tor test-stem; fi
+ - if [[ "$DISTCHECK" != "" && "$TEST_STEM" == "" ]]; then make distcheck DISTCHECK_CONFIGURE_FLAGS="$CONFIGURE_FLAGS"; fi
after_failure:
## configure will leave a log file with more details of config failures.
diff --git a/changes/bug27740 b/changes/bug27740
new file mode 100644
index 0000000000..76a17b7dda
--- /dev/null
+++ b/changes/bug27740
@@ -0,0 +1,4 @@
+ o Minor bugfixes (rust):
+ - Return a string that can be safely freed by C code, not one created by
+ the rust allocator, in protover_all_supported(). Fixes bug 27740; bugfix
+ on 0.3.3.1-alpha.
diff --git a/changes/bug27804 b/changes/bug27804
new file mode 100644
index 0000000000..fa7fec0bc5
--- /dev/null
+++ b/changes/bug27804
@@ -0,0 +1,3 @@
+ o Minor bugfixes (rust):
+ - Fix a potential null dereference in protover_all_supported().
+ Add a test for it. Fixes bug 27804; bugfix on 0.3.3.1-alpha.
diff --git a/changes/bug28115 b/changes/bug28115
new file mode 100644
index 0000000000..e3e29968eb
--- /dev/null
+++ b/changes/bug28115
@@ -0,0 +1,3 @@
+ o Minor bugfixes (portability):
+ - Make the OPE code (which is used for v3 onion services) run correctly
+ on big-endian platforms. Fixes bug 28115; bugfix on 0.3.5.1-alpha.
diff --git a/changes/bug28202 b/changes/bug28202
new file mode 100644
index 0000000000..182daac4f1
--- /dev/null
+++ b/changes/bug28202
@@ -0,0 +1,4 @@
+ o Minor bugfixes (C correctness):
+ - Avoid undefined behavior in an end-of-string check when parsing the
+ BEGIN line in a directory object. Fixes bug 28202; bugfix on
+ 0.2.0.3-alpha.
diff --git a/changes/rust_asan b/changes/rust_asan
new file mode 100644
index 0000000000..1ca7ae6888
--- /dev/null
+++ b/changes/rust_asan
@@ -0,0 +1,8 @@
+ o Major bugfixes (compilation, rust):
+ - Rust tests can now build and run successfully with the
+ --enable-fragile-hardening option enabled.
+ Doing this currently requires the rust beta channel; it will
+ be possible with stable rust as of rust version 1.31 is out.
+ Patch from Alex Crichton.
+ Fixes bugs 27272, 27273, and 27274.
+ Bugfix on 0.3.1.1-alpha.
diff --git a/changes/ticket27751 b/changes/ticket27751
new file mode 100644
index 0000000000..593c473b61
--- /dev/null
+++ b/changes/ticket27751
@@ -0,0 +1,2 @@
+ o Minor features (continuous integration):
+ - Add a Travis CI build for --enable-nss on Linux gcc. Closes ticket 27751.
diff --git a/changes/ticket27913 b/changes/ticket27913
new file mode 100644
index 0000000000..81ce725932
--- /dev/null
+++ b/changes/ticket27913
@@ -0,0 +1,3 @@
+ o Testing:
+ - Add new CI job to Travis configuration that runs stem-based
+ integration tests. Closes ticket 27913.
diff --git a/configure.ac b/configure.ac
index eee30f9cd9..d0de6356da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1210,17 +1210,17 @@ dnl variable.
RUST_LINKER_OPTIONS=""
if test "x$have_clang" = "xyes"; then
if test "x$CFLAGS_ASAN" != "x"; then
- RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS $CFLAGS_ASAN"
+ RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=$CFLAGS_ASAN -Cdefault-linker-libraries"
fi
if test "x$CFLAGS_UBSAN" != "x"; then
- RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS $CFLAGS_UBSAN"
+ RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=$CFLAGS_UBSAN -Cdefault-linker-libraries"
fi
else
if test "x$CFLAGS_ASAN" != "x"; then
- RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -lasan"
+ RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=-fsanitize=address -Cdefault-linker-libraries"
fi
if test "x$CFLAGS_UBSAN" != "x"; then
- RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -lubsan"
+ RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=-fsanitize=undefined -Cdefault-linker-libraries"
fi
fi
AC_SUBST(RUST_LINKER_OPTIONS)
@@ -2416,7 +2416,6 @@ AC_CONFIG_FILES([
Doxyfile
Makefile
config.rust
- link_rust.sh
contrib/dist/suse/tor.sh
contrib/operator-tools/tor.logrotate
contrib/dist/tor.sh
diff --git a/link_rust.sh.in b/link_rust.sh.in
deleted file mode 100644
index 59f4142baa..0000000000
--- a/link_rust.sh.in
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-#
-# A linker script used when building Rust tests. Autoconf makes link_rust.sh
-# from link_rust_sh.in, and uses it to pass extra options to the linker
-# when linking Rust stuff.
-#
-# We'd like to remove the need for this, but build.rs doesn't let us pass
-# -static-libasan and -static-libubsan to the linker.
-
-$CCLD @RUST_LINKER_OPTIONS@ "$@"
diff --git a/src/feature/dirparse/microdesc_parse.c b/src/feature/dirparse/microdesc_parse.c
index 005d2c53d0..aebff5a35f 100644
--- a/src/feature/dirparse/microdesc_parse.c
+++ b/src/feature/dirparse/microdesc_parse.c
@@ -50,13 +50,13 @@ find_start_of_next_microdesc(const char *s, const char *eos)
return NULL;
#define CHECK_LENGTH() STMT_BEGIN \
- if (s+32 > eos) \
+ if (eos - s < 32) \
return NULL; \
STMT_END
#define NEXT_LINE() STMT_BEGIN \
s = memchr(s, '\n', eos-s); \
- if (!s || s+1 >= eos) \
+ if (!s || eos - s <= 1) \
return NULL; \
s++; \
STMT_END
@@ -80,7 +80,7 @@ find_start_of_next_microdesc(const char *s, const char *eos)
/* Okay, now we're pointed at the first line of the microdescriptor which is
not an annotation or onion-key. The next line that _is_ an annotation or
onion-key is the start of the next microdescriptor. */
- while (s+32 < eos) {
+ while (eos - s > 32) {
if (*s == '@' || !strcmpstart(s, "onion-key"))
return s;
NEXT_LINE();
diff --git a/src/feature/dirparse/parsecommon.c b/src/feature/dirparse/parsecommon.c
index c12f199e4e..e00af0eea2 100644
--- a/src/feature/dirparse/parsecommon.c
+++ b/src/feature/dirparse/parsecommon.c
@@ -353,7 +353,7 @@ get_next_token(memarea_t *area,
goto check_object;
obstart = *s; /* Set obstart to start of object spec */
- if (*s+16 >= eol || memchr(*s+11,'\0',eol-*s-16) || /* no short lines, */
+ if (eol - *s <= 16 || memchr(*s+11,'\0',eol-*s-16) || /* no short lines, */
strcmp_len(eol-5, "-----", 5) || /* nuls or invalid endings */
(eol-*s) > MAX_UNPARSED_OBJECT_SIZE) { /* name too long */
RET_ERR("Malformed object: bad begin line");
diff --git a/src/lib/crypt_ops/crypto_ope.c b/src/lib/crypt_ops/crypto_ope.c
index fd5d5f3770..789517eba2 100644
--- a/src/lib/crypt_ops/crypto_ope.c
+++ b/src/lib/crypt_ops/crypto_ope.c
@@ -48,17 +48,17 @@ struct crypto_ope_t {
/** The type to add up in order to produce our OPE ciphertexts */
typedef uint16_t ope_val_t;
-#ifdef WORDS_BIG_ENDIAN
-/** Convert an OPE value to little-endian */
+#ifdef WORDS_BIGENDIAN
+/** Convert an OPE value from little-endian. */
static inline ope_val_t
-ope_val_to_le(ope_val_t x)
+ope_val_from_le(ope_val_t x)
{
return
((x) >> 8) |
(((x)&0xff) << 8);
}
#else
-#define ope_val_to_le(x) (x)
+#define ope_val_from_le(x) (x)
#endif
/**
@@ -104,7 +104,7 @@ sum_values_from_cipher(crypto_cipher_t *c, size_t n)
crypto_cipher_crypt_inplace(c, (char*)buf, BUFSZ*sizeof(ope_val_t));
for (i = 0; i < BUFSZ; ++i) {
- total += ope_val_to_le(buf[i]);
+ total += ope_val_from_le(buf[i]);
total += 1;
}
n -= BUFSZ;
@@ -113,7 +113,7 @@ sum_values_from_cipher(crypto_cipher_t *c, size_t n)
memset(buf, 0, n*sizeof(ope_val_t));
crypto_cipher_crypt_inplace(c, (char*)buf, n*sizeof(ope_val_t));
for (i = 0; i < n; ++i) {
- total += ope_val_to_le(buf[i]);
+ total += ope_val_from_le(buf[i]);
total += 1;
}
diff --git a/src/rust/Cargo.lock b/src/rust/Cargo.lock
index 1d2a7359aa..7d6a6635c5 100644
--- a/src/rust/Cargo.lock
+++ b/src/rust/Cargo.lock
@@ -26,6 +26,7 @@ version = "0.0.1"
dependencies = [
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"smartlist 0.0.1",
+ "tor_allocate 0.0.1",
]
[[package]]
diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml
index e399dbb33a..83f9629660 100644
--- a/src/rust/Cargo.toml
+++ b/src/rust/Cargo.toml
@@ -13,19 +13,3 @@ members = [
[profile.release]
debug = true
panic = "abort"
-
-[features]
-default = []
-# If this feature is enabled, test code which calls Tor C code from Rust will
-# execute with `cargo test`. Due to numerous linker issues (#25386), this is
-# currently disabled by default. Crates listed here are those which, in their
-# unittests, doctests, and/or integration tests, call C code.
-test-c-from-rust = [
- "crypto/test-c-from-rust",
-]
-
-# We have to define a feature here because doctests don't get cfg(test),
-# and we need to disable some C dependencies when running the doctests
-# because of the various linker issues. See
-# https://github.com/rust-lang/rust/issues/45599
-test_linking_hack = []
diff --git a/src/rust/crypto/Cargo.toml b/src/rust/crypto/Cargo.toml
index 6ebfe0dc11..a7ff7f78d9 100644
--- a/src/rust/crypto/Cargo.toml
+++ b/src/rust/crypto/Cargo.toml
@@ -9,7 +9,6 @@ build = "../build.rs"
[lib]
name = "crypto"
path = "lib.rs"
-crate_type = ["rlib", "staticlib"]
[dependencies]
libc = "=0.2.39"
diff --git a/src/rust/external/Cargo.toml b/src/rust/external/Cargo.toml
index 4735144ee6..5f443645bb 100644
--- a/src/rust/external/Cargo.toml
+++ b/src/rust/external/Cargo.toml
@@ -5,14 +5,12 @@ name = "external"
[dependencies]
libc = "=0.2.39"
-
-[dependencies.smartlist]
-path = "../smartlist"
+smartlist = { path = "../smartlist" }
+tor_allocate = { path = "../tor_allocate" }
[lib]
name = "external"
path = "lib.rs"
-crate_type = ["rlib", "staticlib"]
[features]
# We have to define a feature here because doctests don't get cfg(test),
diff --git a/src/rust/external/lib.rs b/src/rust/external/lib.rs
index b72a4f6e4c..d68036fcad 100644
--- a/src/rust/external/lib.rs
+++ b/src/rust/external/lib.rs
@@ -8,7 +8,7 @@
//! module implementing this functionality repeatedly.
extern crate libc;
-
+extern crate tor_allocate;
extern crate smartlist;
pub mod crypto_digest;
diff --git a/src/rust/protover/Cargo.toml b/src/rust/protover/Cargo.toml
index 2f7783e76c..84a7c71c1a 100644
--- a/src/rust/protover/Cargo.toml
+++ b/src/rust/protover/Cargo.toml
@@ -31,4 +31,3 @@ path = "../tor_log"
[lib]
name = "protover"
path = "lib.rs"
-crate_type = ["rlib", "staticlib"]
diff --git a/src/rust/protover/ffi.rs b/src/rust/protover/ffi.rs
index 940f923327..ac149fbbbc 100644
--- a/src/rust/protover/ffi.rs
+++ b/src/rust/protover/ffi.rs
@@ -62,6 +62,9 @@ pub extern "C" fn protover_all_supported(
};
if let Some(unsupported) = relay_proto_entry.all_supported() {
+ if missing_out.is_null() {
+ return 0;
+ }
let c_unsupported: CString = match CString::new(unsupported.to_string()) {
Ok(n) => n,
Err(_) => return 1,
diff --git a/src/rust/smartlist/Cargo.toml b/src/rust/smartlist/Cargo.toml
index 4ecdf50869..a5afe7bf74 100644
--- a/src/rust/smartlist/Cargo.toml
+++ b/src/rust/smartlist/Cargo.toml
@@ -9,7 +9,6 @@ libc = "0.2.39"
[lib]
name = "smartlist"
path = "lib.rs"
-crate_type = ["rlib", "staticlib"]
[features]
# We have to define a feature here because doctests don't get cfg(test),
diff --git a/src/rust/smartlist/lib.rs b/src/rust/smartlist/lib.rs
index 2716842af2..34d0b907ed 100644
--- a/src/rust/smartlist/lib.rs
+++ b/src/rust/smartlist/lib.rs
@@ -6,3 +6,12 @@ extern crate libc;
mod smartlist;
pub use smartlist::*;
+
+// When testing we may be compiled with sanitizers which are incompatible with
+// Rust's default allocator, jemalloc (unsure why at this time). Most crates
+// link to `tor_allocate` which switches by default to a non-jemalloc allocator,
+// but we don't already depend on `tor_allocate` so make sure that while testing
+// we don't use jemalloc. (but rather malloc/free)
+#[global_allocator]
+#[cfg(test)]
+static A: std::alloc::System = std::alloc::System;
diff --git a/src/rust/tor_allocate/Cargo.toml b/src/rust/tor_allocate/Cargo.toml
index 7bb3b9887f..06ac605f17 100644
--- a/src/rust/tor_allocate/Cargo.toml
+++ b/src/rust/tor_allocate/Cargo.toml
@@ -9,7 +9,6 @@ libc = "=0.2.39"
[lib]
name = "tor_allocate"
path = "lib.rs"
-crate_type = ["rlib", "staticlib"]
[features]
# We have to define a feature here because doctests don't get cfg(test),
diff --git a/src/rust/tor_allocate/lib.rs b/src/rust/tor_allocate/lib.rs
index 5a355bc8d6..1cfa0b5178 100644
--- a/src/rust/tor_allocate/lib.rs
+++ b/src/rust/tor_allocate/lib.rs
@@ -11,5 +11,10 @@
extern crate libc;
+use std::alloc::System;
+
mod tor_allocate;
pub use tor_allocate::*;
+
+#[global_allocator]
+static A: System = System;
diff --git a/src/rust/tor_log/Cargo.toml b/src/rust/tor_log/Cargo.toml
index 1aa9be0612..14d9ae803a 100644
--- a/src/rust/tor_log/Cargo.toml
+++ b/src/rust/tor_log/Cargo.toml
@@ -6,7 +6,6 @@ authors = ["The Tor Project"]
[lib]
name = "tor_log"
path = "lib.rs"
-crate_type = ["rlib", "staticlib"]
[features]
# We have to define a feature here because doctests don't get cfg(test),
diff --git a/src/rust/tor_log/tor_log.rs b/src/rust/tor_log/tor_log.rs
index 5231d0c631..757c74ff49 100644
--- a/src/rust/tor_log/tor_log.rs
+++ b/src/rust/tor_log/tor_log.rs
@@ -89,15 +89,15 @@ pub mod log {
use super::LogSeverity;
use libc::{c_char, c_int};
- /// Severity log types. These mirror definitions in /src/common/torlog.h
- /// C_RUST_COUPLED: src/common/log.c, log domain types
+ /// Severity log types. These mirror definitions in src/lib/log/log.h
+ /// C_RUST_COUPLED: src/lib/log/log.c, log domain types
extern "C" {
static LOG_WARN_: c_int;
static LOG_NOTICE_: c_int;
}
- /// Domain log types. These mirror definitions in /src/common/torlog.h
- /// C_RUST_COUPLED: src/common/log.c, log severity types
+ /// Domain log types. These mirror definitions in src/lib/log/log.h
+ /// C_RUST_COUPLED: src/lib/log/log.c, log severity types
extern "C" {
static LD_NET_: u32;
static LD_GENERAL_: u32;
diff --git a/src/rust/tor_rust/Cargo.toml b/src/rust/tor_rust/Cargo.toml
index 1523ee0dd1..35c629882e 100644
--- a/src/rust/tor_rust/Cargo.toml
+++ b/src/rust/tor_rust/Cargo.toml
@@ -6,7 +6,7 @@ version = "0.1.0"
[lib]
name = "tor_rust"
path = "lib.rs"
-crate_type = ["rlib", "staticlib"]
+crate_type = ["staticlib"]
[dependencies.tor_util]
path = "../tor_util"
diff --git a/src/rust/tor_util/Cargo.toml b/src/rust/tor_util/Cargo.toml
index 51e4bd9c5d..9ffaeda8a6 100644
--- a/src/rust/tor_util/Cargo.toml
+++ b/src/rust/tor_util/Cargo.toml
@@ -6,7 +6,6 @@ version = "0.0.1"
[lib]
name = "tor_util"
path = "lib.rs"
-crate_type = ["rlib", "staticlib"]
[dependencies.tor_allocate]
path = "../tor_allocate"
diff --git a/src/test/include.am b/src/test/include.am
index 1055cd0a81..ecb7689579 100644
--- a/src/test/include.am
+++ b/src/test/include.am
@@ -12,8 +12,7 @@ TESTS_ENVIRONMENT = \
export EXTRA_CARGO_OPTIONS="$(EXTRA_CARGO_OPTIONS)"; \
export CARGO_ONLINE="$(CARGO_ONLINE)"; \
export CCLD="$(CCLD)"; \
- chmod +x "$(abs_top_builddir)/link_rust.sh"; \
- export RUSTFLAGS="-C linker=$(abs_top_builddir)/link_rust.sh";
+ export RUSTFLAGS="-C linker=`echo '$(CC)' | cut -d' ' -f 1` $(RUST_LINKER_OPTIONS)";
TESTSCRIPTS = \
src/test/fuzz_static_testcases.sh \
diff --git a/src/test/test_protover.c b/src/test/test_protover.c
index b835e28ab5..5f9a8b7937 100644
--- a/src/test/test_protover.c
+++ b/src/test/test_protover.c
@@ -268,6 +268,7 @@ test_protover_all_supported(void *arg)
tt_ptr_op(msg, OP_EQ, NULL);
// Some things we don't support
+ tt_assert(! protover_all_supported("Wombat=9", NULL));
tt_assert(! protover_all_supported("Wombat=9", &msg));
tt_str_op(msg, OP_EQ, "Wombat=9");
tor_free(msg);
diff --git a/src/test/test_rust.sh b/src/test/test_rust.sh
index a1a56af480..00b3e88d37 100755
--- a/src/test/test_rust.sh
+++ b/src/test/test_rust.sh
@@ -5,12 +5,20 @@ set -e
export LSAN_OPTIONS=suppressions=${abs_top_srcdir:-../../..}/src/test/rust_supp.txt
+# When testing Cargo we pass a number of very specific linker flags down
+# through Cargo. We do not, however, want these flags to affect things like
+# build scripts, only the tests that we're compiling. To ensure this happens
+# we unconditionally pass `--target` into Cargo, ensuring that `RUSTFLAGS` in
+# the environment won't make their way into build scripts.
+rustc_host=$(rustc -vV | grep host | sed 's/host: //')
+
for cargo_toml_dir in "${abs_top_srcdir:-../../..}"/src/rust/*; do
if [ -e "${cargo_toml_dir}/Cargo.toml" ]; then
cd "${abs_top_builddir:-../../..}/src/rust" && \
CARGO_TARGET_DIR="${abs_top_builddir:-../../..}/src/rust/target" \
"${CARGO:-cargo}" test ${CARGO_ONLINE-"--frozen"} \
- --features "test_linking_hack" \
+ --features "test_linking_hack" \
+ --target $rustc_host \
${EXTRA_CARGO_OPTIONS} \
--manifest-path "${cargo_toml_dir}/Cargo.toml" || exitcode=1
fi