summaryrefslogtreecommitdiff
path: root/src/common/address.c
AgeCommit message (Collapse)Author
2015-09-29Add checks and unit tests for get_interface_address* failureteor (Tim Wilson-Brown)
Ensure that either a valid address is returned in address pointers, or that the address data is zeroed on error. Ensure that free_interface_address6_list handles NULL lists. Add unit tests for get_interface_address* failure cases. Fixes bug #17173. Patch by fk/teor, not in any released version of tor.
2015-09-29get_interface_address6_list(): Bring back a return code checkFabian Keil
... that was removed by 31eb486c46 which first appeared in 0.2.7.3-rc. If tor is running in a ElectroBSD (or FreeBSD) jail it can't get any IP addresses that aren't assigned to the jail by looking at the interfaces and (by design) the get_interface_address6_via_udp_socket_hack() fallback doesn't work either. The missing return code check resulted in tor_addr_is_internal() complaining about a "non-IP address of type 49", due to reading uninitialised memory. Fixes #17173.
2015-09-16Merge branch 'bug17027-reject-private-all-interfaces-v2' into bug16069-bug17027teor (Tim Wilson-Brown)
src/test/test_policy.c: Merged calls to policies_parse_exit_policy by adding additional arguments. fixup to remaining instance of ~EXIT_POLICY_IPV6_ENABLED. Compacting logic test now produces previous list length of 4, corrected this. src/config/torrc.sample.in: src/config/torrc.minimal.in-staging: Merged torrc modification dates in favour of latest.
2015-09-16ExitPolicyRejectPrivate rejects local IPv6 address and interface addressesteor (Tim Wilson-Brown)
ExitPolicyRejectPrivate now rejects more local addresses by default: * the relay's published IPv6 address (if any), and * any publicly routable IPv4 or IPv6 addresses on any local interfaces. This resolves a security issue for IPv6 Exits and multihomed Exits that trust connections originating from localhost. Resolves ticket 17027. Patch by "teor". Patch on 42b8fb5a1523 (11 Nov 2007), released in 0.2.0.11-alpha.
2015-09-16ExitPolicy accept6/reject6 produces IPv6 wildcard addresses onlyteor (Tim Wilson-Brown)
In previous versions of Tor, ExitPolicy accept6/reject6 * produced policy entries for IPv4 and IPv6 wildcard addresses. To reduce operator confusion, change accept6/reject6 * to only produce an IPv6 wildcard address. Resolves bug #16069. Patch on 2eb7eafc9d78 and a96c0affcb4c (25 Oct 2012), released in 0.2.4.7-alpha.
2015-09-16Ignore accept6/reject6 IPv4, warn about unexpected rule outcomesteor (Tim Wilson-Brown)
When parsing torrc ExitPolicies, we now warn if: * an IPv4 address is used on an accept6 or reject6 line. The line is ignored, but the rest of the policy items in the list are used. (accept/reject continue to allow both IPv4 and IPv6 addresses in torrcs.) * a "private" address alias is used on an accept6 or reject6 line. The line filters both IPv4 and IPv6 private addresses, disregarding the 6 in accept6/reject6. When parsing torrc ExitPolicies, we now issue an info-level message: * when expanding an accept/reject * line to include both IPv4 and IPv6 wildcard addresses. In each instance, usage advice is provided to avoid the message. Partial fix for ticket 16069. Patch by "teor". Patch on 2eb7eafc9d78 and a96c0affcb4c (25 Oct 2012), released in 0.2.4.7-alpha.
2015-09-15Add get_interface_address[6]_list for a list of interface IP addressesteor (Tim Wilson-Brown)
Add get_interface_address[6]_list by refactoring get_interface_address6. Add unit tests for new and existing functions. Preparation for ticket 17027. Patch by "teor". Patch on 42b8fb5a1523 (11 Nov 2007), released in 0.2.0.11-alpha.
2015-07-31Move formatting functions around.Nick Mathewson
The base64 and base32 functions used to be in crypto.c; crypto_format.h had no header; some general-purpose functions were in crypto_curve25519.c. This patch makes a {crypto,util}_format.[ch], and puts more functions there. Small modules are beautiful!
2015-06-29Try a little harder to fix the tor-ci-windows builder, or figure out why it ↵Nick Mathewson
is broke
2015-06-29Remove checks for visual C 6.Nick Mathewson
2015-03-31Merge branch 'ticket14710_squashed'Nick Mathewson
2015-03-31Whitebox test for get_interface_address6_via_udp_socket_hack().rl1987
Also, fix some whitespace mishaps.
2015-03-31Bugfix: we don't want loopback/multicastaddress from _hack().rl1987
2015-03-31Moving the hacky part of get_interface_address6() into separate function.rl1987
2015-02-16Fix deadcode warning in get_interface_addresses_raw().Nick Mathewson
CID 1268070
2015-02-16Fix a trivial double-close in address.c. CID 1268071Nick Mathewson
2015-02-12Avoid undefined behaviour in ifreq_to_smartlistSebastian Hahn
This could trigger where _SIZEOF_ADDR_IFREQ() might not return a multiple of sizeof(void *). Fixes bug 14875; not in any released version of Tor.
2015-02-12Actually get all interface addressesSebastian Hahn
If we guessed a buffer size too small, we never increased the buffer and tried again Also simplify the interface of ifreq_to_smartlist a little
2015-01-23Merge branch 'if_addr_refactoring_squashed'Nick Mathewson
Conflicts: src/test/include.am src/test/test.c
2015-01-23Refactor code that looks up addresses from interfacesrl1987
Now the code has separate implementation and examination functions, uses smartlists sanely, and has relatively decent test coverage.
2015-01-07Commit second draft of Jake's SOCKS5-over-AF_UNIX patch. See ticket #12585.Jacob Appelbaum
Signed-off-by: Andrea Shepard <andrea@torproject.org>
2015-01-02Bump copyright dates to 2015, in case someday this matters.Nick Mathewson
2014-12-30Remove a logically dead check to please coverityNick Mathewson
2014-12-29Wipe all of the target space in tor_addr_{to,from}_sockaddr()Nick Mathewson
Otherwise we risk a subsequent memdup or memcpy copying uninitialized RAM into some other place that might eventually expose it. Let's make sure that doesn't happen. Closes ticket 14041
2014-12-29Merge branch 'resolvemyaddr_squashed'Nick Mathewson
2014-12-29Adding comprehensive test cases for resolve_my_address.rl1987
Also, improve comments on resolve_my_address to explain what it actually does.
2014-12-21Fix a comment in tor_addr_parseteor
2014-11-12Merge remote-tracking branch 'public/bug7484'Nick Mathewson
Conflicts: src/test/test_addr.c
2014-10-28Add another year to our copyright dates.Nick Mathewson
Because in 95 years, we or our successors will surely care about enforcing the BSD license terms on this code. Right?
2014-10-23Fix minor typos, two line lengths, and a repeated includeteor
2014-09-25Tell autoconf to make the compiler act as c99Nick Mathewson
Apparently some compilers want extra switches.
2014-09-25Tweak address.c to use a little c99 syntaxNick Mathewson
Since address.c is the first file to get compiled, let's have it use a little judicious c99 in order to catch broken compilers that somehow make it past our autoconf tests.
2014-09-15Clear up another clangalyzer issueNick Mathewson
"The NULL pointer warnings on the return value of tor_addr_to_in6_addr32() are incorrect. But clang can't work this out itself due to limited analysis depth. To teach the analyser that the return value is safe to dereference, I applied tor_assert to the return value." Patch from teor. Part of 13157.
2014-09-02Fix a number of clang analyzer false-positivesNick Mathewson
Most of these are in somewhat non-obvious code where it is probably a good idea to initialize variables and add extra assertions anyway. Closes 13036. Patches from "teor".
2014-05-22sandbox: revamp sandbox_getaddrinfo cacheingNick Mathewson
The old cache had problems: * It needed to be manually preloaded. (It didn't remember any address you didn't tell it to remember) * It was AF_INET only. * It looked at its cache even if the sandbox wasn't turned on. * It couldn't remember errors. * It had some memory management problems. (You can't use memcpy to copy an addrinfo safely; it has pointers in.) This patch fixes those issues, and moves to a hash table. Fixes bug 11970; bugfix on 0.2.5.1-alpha.
2014-04-18scan-build: Add a check for result from getaddrinfoNick Mathewson
As documented, getaddrinfo always sets its result when it returns no error. But scan-build doesn't know that, and thinks we might be def
2014-04-05Merge remote-tracking branch 'public/bug10801_024'Nick Mathewson
Conflicts: src/common/address.c src/or/config.c
2014-04-05Make tor_addr_port_parse handle portless IPv6 addresses correctly.Nick Mathewson
(Not a bugfix on any Tor release; before 10801_024, it didn't handle portless addresses at all.)
2014-04-01Merge remote-tracking branch 'public/bug4645'Nick Mathewson
Conflicts: src/or/dirserv.c
2014-04-01Merge remote-tracking branch 'public/bug11232'Nick Mathewson
2014-03-27Don't do a DNS lookup on a bridge line addressNick Mathewson
Fixes bug 10801; bugfix on 07bf274d in 0.2.0.1-alpha.
2014-03-25Fix warnings from doxygenNick Mathewson
Most of these are simple. The only nontrivial part is that our pattern for using ENUM_BF was confusing doxygen by making declarations that didn't look like declarations.
2014-03-18Fix a ubsan warning in addr_mask_get_bitsNick Mathewson
ubsan doesn't like us to do (1u<<32) when 32 is wider than unsigned. Fortunately, we already special-case addr_mask_get_bits(0), so we can just change the loop bounds.
2014-02-12Disallow "*/maskbits" as an address pattern.Nick Mathewson
Fixes bug 7484. We've had this bug back in a8eaa79e031ee04d44 in 0.0.2pre14, when we first started allowing address masks.
2014-02-12Siphash-2-4 is now our hash in nearly all cases.Nick Mathewson
I've made an exception for cases where I'm sure that users can't influence the inputs. This is likely to cause a slowdown somewhere, but it's safer to siphash everything and *then* look for cases to optimize. This patch doesn't actually get us any _benefit_ from siphash yet, since we don't really randomize the key at any point.
2014-02-03Removing is_internal_IP() function. Resolves ticket 4645.rl1987
2013-10-08Merge remote-tracking branch 'origin/maint-0.2.4'Nick Mathewson
2013-10-08When examining interfaces to find an address, discard non-up ones.Nick Mathewson
Patch from "hantwister" on trac. Fixes bug #9904; bugfix on 0.2.3.11-alpha.
2013-09-09Fix compilation on OSXNick Mathewson
2013-09-06passing hints as a const pointer to sandbox_getaddrinfo(), also one tor_free ↵Cristian Toader
macro fails to compile..