Commit Graph

1410 Commits

Author SHA1 Message Date
cypherpunks
4ae555face Fix memory leak in ntor test 2015-12-08 08:28:27 -05:00
teor (Tim Wilson-Brown)
7ff18cc1b6 Avoid relying on malloc internals in test_rend_cache_purge.
Closes ticket 17724. Bug fix on ade5005853 and 5e9f2384cf,
not in any released version of Tor. Patch by "teor".
2015-12-01 10:50:14 +11:00
cypherpunks
8ce70fcbf3 Fix memory leak in policies test 2015-11-27 11:54:47 -05:00
teor (Tim Wilson-Brown)
fc264975b1 Unit test the full length of SHA256 and SHA512 digests
Bugfix on a tor version before the refactoring in git commit
cea1225199 (23 Sep 2009). Patch by "teor".
2015-11-27 02:25:31 +11:00
Nick Mathewson
09e0ae0588 Merge remote-tracking branch 'teor/rand-failure-modes-v2' 2015-11-26 10:05:38 -05:00
Nick Mathewson
0285054189 Fix buffer size in sha512 unit test
Nobody likes a stack overflow, even in unit tests.

Closes 17699; but not in any released tor.
2015-11-26 10:00:12 -05:00
Nick Mathewson
fe46fffd98 Fix test_tortls.c to no longer test failing crypto_rand.
(crypto_rand is no longer allowed to fail.)

Closes bug 17686; bug not in any released tor.  (No backport, since
the tortls tests aren't in 0.2.7)
2015-11-26 09:34:44 -05:00
teor (Tim Wilson-Brown)
155fa2dbdb Add unit tests that check for common RNG failure modes
Check that crypto_rand doesn't return all zeroes, identical values,
or incrementing values (OpenSSL's rand_predictable feature).
2015-11-26 21:27:05 +11:00
Nick Mathewson
e5754c42d1 Merge branch 'bug17686_v2_027' 2015-11-25 22:33:49 -05:00
Nick Mathewson
ddcbe26474 Now that crypto_rand() cannot fail, it should return void. 2015-11-25 22:29:59 -05:00
Nick Mathewson
10fdee6285 Add crypto-initializer functions to those whose return values must be checked 2015-11-25 22:29:59 -05:00
Nick Mathewson
dedea28c2e Make crypto_seed_rng() and crypto_rand() less scary.
These functions must really never fail; so have crypto_rand() assert
that it's working okay, and have crypto_seed_rng() demand that
callers check its return value.  Also have crypto_seed_rng() check
RAND_status() before returning.
2015-11-25 22:29:59 -05:00
teor (Tim Wilson-Brown)
e14f9dd44f fixup! Add controller getinfo exit-policy/reject-private
Stop ignoring ExitPolicyRejectPrivate in getinfo
exit-policy/reject-private. Fix a memory leak.

Set ExitPolicyRejectPrivate in the unit tests, and make a mock
function declaration static.
2015-11-25 22:26:10 -05:00
cypherpunks
c59c622d85 Initialize libevent before periodic events
The initialization of libevent interferes with other tests so we also
fork the circuit_timeout test.
2015-11-25 09:38:46 -05:00
teor (Tim Wilson-Brown)
a09e7cd31a fixup! Block OutboundBindAddressIPv[4|6]_ and configured ports on exit relays
Fix unit tests for get_interface_address6_list to assume less
about the interface addresses on the system.

Instead, mock get_interface_address6_list and use the mocked
function to provide a range of address combinations.
2015-11-25 09:31:27 -05:00
Nick Mathewson
74e5385da7 Merge remote-tracking branch 'gtank/feature17663' 2015-11-25 09:00:01 -05:00
George Tankersley
ff54cc8481 add SHA512 support to crypto 2015-11-24 01:34:28 +00:00
teor (Tim Wilson-Brown)
2e9779e5d8 Use SHA256 in the replaycache, rather than SHA1
This migrates away from SHA1, and provides further hash flooding
protection on top of the randomised siphash implementation.

Add unit tests to make sure that different inputs don't have the
same hash.
2015-11-24 09:08:53 +11:00
Nick Mathewson
cbc1b8a4f7 fix "make check-spaces" 2015-11-20 10:52:56 -05:00
Nick Mathewson
e3cf39cefd Fix compilation warnings 2015-11-20 10:51:19 -05:00
Nick Mathewson
35e886fe13 Merge branch 'getinfo-private-exitpolicy-v4-squashed' 2015-11-20 10:48:28 -05:00
teor (Tim Wilson-Brown)
10a6390deb Add controller getinfo exit-policy/reject-private
exit-policy/reject-private lists the reject rules added by
ExitPolicyRejectPrivate. This makes it easier for stem to
display exit policies.

Add unit tests for getinfo exit-policy/*.

Completes ticket #17183. Patch by "teor".
2015-11-20 10:48:19 -05:00
teor (Tim Wilson-Brown)
66fac9fbad Block OutboundBindAddressIPv[4|6]_ and configured ports on exit relays
Modify policies_parse_exit_policy_reject_private so it also blocks
the addresses configured for OutboundBindAddressIPv4_ and
OutboundBindAddressIPv6_, and any publicly routable port addresses
on exit relays.

Add and update unit tests for these functions.
2015-11-20 10:39:13 +11:00
teor (Tim Wilson-Brown)
e726ad4664 Add unit tests for policies_parse_exit_policy_reject_private
Test that policies_parse_exit_policy_reject_private rejects supplied
IPv4 and IPv6 relay addresses, and the addresses of local interfaces.
2015-11-20 10:32:51 +11:00
Nick Mathewson
35bfd782ea Merge remote-tracking branch 'teor/bug17632-no-ipv4-no-localhost-squashed' 2015-11-19 11:19:31 -05:00
teor (Tim Wilson-Brown)
f19d6b81c8 Fixup #17638: ignore EINVAL from FreeBSD jails without ::1
In my testing, an IPv6-only FreeBSD jail without ::1 returned EINVAL
from tor_ersatz_socketpair. Let's not fail the unit test because of
this - it would only ever use tor_socketpair() anyway.
2015-11-19 19:20:01 +11:00
teor (Tim Wilson-Brown)
53ec840bdf Make tor_ersatz_socketpair work on IPv6-only systems
(But it won't work on some systems without IPv4/IPv6 localhost
(some BSD jails) by design, to avoid creating sockets on routable
IP addresses. However, those systems likely have the AF_UNIX socketpair,
which tor prefers.)

Fixes bug #17638; bugfix on a very early tor version,
earlier than 22dba27d8d (23 Nov 2004) / svn:r2943.

Patch by "teor".
2015-11-19 19:08:22 +11:00
Nick Mathewson
913fbf8f2f Merge remote-tracking branch 'teor/bug17632-no-ipv4-no-localhost' 2015-11-18 15:02:45 -05:00
teor (Tim Wilson-Brown)
71fd66c866 Fix unit tests on systems without IPv4 or localhost addresses
Make unit tests pass on IPv6-only systems, and systems without
localhost addresses (like some FreeBSD jails).

Fixes:
* get_if_addrs_ifaddrs: systems without localhost
* get_if_addrs_ioctl: only works on IPv4 systems
* socket: check IPv4 and IPv6, skip on EPROTONOSUPPORT
* socketpair_ersatz: uses IPv4, skip on EPROTONOSUPPORT

Fixes bug #17632; bugfix on unit tests in 0.2.7.3-rc.
c464a36772 was a partial fix for this issue in #17255;
it was released in unit tests in 0.2.7.4-rc.

Patch by "teor".
2015-11-19 00:41:06 +11:00
teor (Tim Wilson-Brown)
a1ce111d32 Really Really Fixup 86eba14ac5: Windows support, error return values 2015-11-19 00:13:58 +11:00
teor (Tim Wilson-Brown)
eed86892dd Really Fixup 86eba14ac5: error return values are negative 2015-11-18 23:54:26 +11:00
teor (Tim Wilson-Brown)
3351f69c75 Fixup 86eba14ac5: add errno.h for EPROTONOSUPPORT 2015-11-18 23:47:12 +11:00
teor (Tim Wilson-Brown)
86eba14ac5 Fix unit tests on systems without IPv4 or localhost addresses
Make unit tests pass on IPv6-only systems, and systems without
localhost addresses (like some FreeBSD jails).

Fixes:
* get_if_addrs_ifaddrs: systems without localhost
* get_if_addrs_ioctl: only works on IPv4 systems
* socket: check IPv4 and IPv6, skip on EPROTONOSUPPORT
* socketpair_ersatz: uses IPv4, skip on EPROTONOSUPPORT

Fixes bug #17632; bugfix on unit tests in 0.2.7.3-rc.
c464a36772 was a partial fix for this issue in #17255;
it was released in unit tests in 0.2.7.4-rc.

Patch by "teor".
2015-11-18 23:25:21 +11:00
Nick Mathewson
70f337fdb2 Some unit tests now require that periodic events be initialized. 2015-11-17 09:26:50 -05:00
Nick Mathewson
d467227323 Merge remote-tracking branch 'public/ticket11150_client_only' 2015-11-13 09:58:16 -05:00
Nick Mathewson
d20a3d07e3 Merge branch 'karsten_bug13192_026_03_teor' 2015-11-12 11:40:58 -05:00
Nick Mathewson
1f7ba115a4 Rename cast_double_to_int64 to clamp_double_to_int64 2015-11-12 11:33:48 -05:00
Nick Mathewson
0694263b75 Make round_to_next_multiple_of always round upwards.
Yes, even if it has to return a non-multiple.  This prevents us from
ever having a bug where we try to use it for allocation, and under-allocate.
2015-11-12 11:32:14 -05:00
Nick Mathewson
0a3eed5f20 Merge branch 'bug17549' 2015-11-10 10:40:31 -05:00
Yawning Angel
6512df34a4 Fix the tortls.c unit tests to pass with OpenSSL 1.1.0-dev.
The string description for the states got changed slightly.
2015-11-06 19:42:39 +00:00
Yawning Angel
89cb2e467d Fix compilation with OpenSSL 1.1.0 --enable-gcc-warnings is set. 2015-11-06 19:12:43 +00:00
Nick Mathewson
af80d472f7 "And now a better patch which builds the tests if LibreSSL is used."
Works on the latest LibreSSL (in OpenBSD-current).

(Patch from 'rubiate' on #17253.
2015-11-06 10:58:00 -05:00
Nick Mathewson
1385ab0605 Merge remote-tracking branch 'rl1987/ticket16831_part2_rebased' 2015-10-30 09:59:11 -04:00
rl1987
2e980e9a2e Fix GCC warnings. 2015-10-29 13:12:29 +01:00
Nick Mathewson
19e10f95c1 Merge remote-tracking branch 'rl1987/bug17417_take2' 2015-10-26 09:18:48 -04:00
rl1987
e2f9c7d54f Avoid crashing due to double-freeing memory. 2015-10-24 16:21:35 +03:00
rl1987
a187c772af Seventh test case for dns_resolve_impl(). 2015-10-24 14:30:53 +03:00
rl1987
f53dcf6a35 Sixth test case for dns_resolve_impl. 2015-10-24 14:30:52 +03:00
rl1987
cc1bed9974 Add a fifth unit test. 2015-10-24 14:30:52 +03:00
rl1987
bb8ec2e1c6 Whitespace fixes. 2015-10-24 14:30:52 +03:00