Commit Graph

24535 Commits

Author SHA1 Message Date
Nick Mathewson
a727d4a3a1 Remove unused struct_var_* functions.
These turned out to be unnecessary, so let's not keep them around
and let them start getting complicated.

Closes ticket 31630.
2019-09-05 15:24:54 -04:00
Nick Mathewson
16cf9424c1 config: Invert sense of _is_invisible, and rename to is_listable() 2019-09-05 11:32:32 -04:00
Nick Mathewson
22e7d33735 config: replace config_var_is_cumulative with is_replaced_on_set()
This change replaces the higher-level property check to match our
intended flag factoring.
2019-09-05 11:32:32 -04:00
George Kadianakis
545c21e23d Merge branch 'tor-github/pr/1295' 2019-09-05 17:13:29 +03:00
George Kadianakis
ddd01541b9 Merge branch 'tor-github/pr/1294' 2019-09-05 17:12:19 +03:00
George Kadianakis
fb56b4c2bf Merge branch 'tor-github/pr/1293' 2019-09-05 17:10:07 +03:00
George Kadianakis
c750ec20ab Merge branch 'tor-github/pr/1291' 2019-09-05 17:09:20 +03:00
George Kadianakis
c29f05b159 Merge branch 'tor-github/pr/1292' 2019-09-05 17:06:58 +03:00
George Kadianakis
cdd7e88970 Merge branch 'tor-github/pr/1261' 2019-09-05 17:02:53 +03:00
Neel Chauhan
0127888b06 Add tests for IPv6 exit policies on microdescriptors 2019-09-05 17:02:45 +03:00
Neel Chauhan
be4a60945d Check IPv6 exit policies on microdescriptors in node_exit_policy_rejects_all() 2019-09-05 17:02:45 +03:00
Nick Mathewson
eb909c4e43 config: note that some arguments are required. 2019-09-05 07:57:36 -04:00
teor
1203e137be
Merge commit '763fd0ad66' into maint-0.4.0
tor-github/pr/1174, but with the last commit re-worded to remove
the fixup, because fixups break our push rules.
2019-09-05 11:42:26 +10:00
Nick Mathewson
88839ab2ac Remove _ex suffix from typed_var_*_ex() functions.
Now that the variants of these functions that took config_line_t are
gone, there is no longer any reason for the remaining variants to
have "ex" at the end of their names.

This commit was made by running this perl script over all the files
in src/:

#!/usr/bin/perl -w -i -p

s{typed_var_(assign|free|encode|copy|eq|ok|kvassign|kvencode|mark_fragile)_ex}
 {typed_var_$1}g;
2019-09-04 15:01:49 -04:00
Nick Mathewson
161c392a4f typedvar: remove now-unused functions taking config_type_t.
These functions are no longer used.

Part of 31629.
2019-09-04 14:54:59 -04:00
Nick Mathewson
b3c2867715 Document fields of struct_magic_decl_t. 2019-09-04 14:23:19 -04:00
Nick Mathewson
3db56aeeb8 Document warn_deprecated_option(). 2019-09-04 14:23:19 -04:00
Nick Mathewson
39316da9b6 Document return value of config_mgr_add_format(). 2019-09-04 14:23:19 -04:00
Nick Mathewson
39dd2e2aa8 Document validate_fn_t as it stands.
Also document that it will be changed in a later branch.
2019-09-04 14:23:19 -04:00
Nick Mathewson
aeda598fd5 config_assign: Document CAL_* options.
These were sort of described in config_assign() documentation, but
not so well.
2019-09-04 14:23:19 -04:00
Nick Mathewson
577ea20b3a Document configuration and abbreviation types. 2019-09-04 14:23:19 -04:00
Nick Mathewson
3aba13f779 buffers: use ptrdiff_t to indicate offsets.
Previously we used int in some places and off_t for others.  Neither
is correct: ptrdiff_t is right for differences between pointers.
(off_t is only for offsets and sizes on the filesystem.)
2019-09-04 12:06:27 -04:00
Nick Mathewson
ec724fe8c8 rendclient: use ptrdiff, not off_t, for offset of DH field.
The off_t type is only useful for offsets on the filesystem.  For
in-memory offsets, use ptrdiff_t.
2019-09-04 12:06:27 -04:00
Nick Mathewson
b39ee42904 compat_compiler: fix documentation for STRUCT_VAR_P
Previously we had said that off_t was a reasonable type to hold the
result of offsetof().  That isn't so: ptrdiff_t is correct.
2019-09-04 12:06:27 -04:00
Nick Mathewson
dc199f40fb smartlist_pqueue: use ptrdiff_t instead of int for offsets.
This is technically correct, but should not matter in practice,
since we don't use this on any structs whose size exceeds INT_MAX.
2019-09-04 12:06:27 -04:00
Nick Mathewson
03ce67d378 config: explain CONFIG_TYPE_EXTENDED
Also add an explanation of a possible future refactoring where we
might remove the config_type_t enumeration entierly.

Fixes ticket 31624.

No changes file, since this is a comment-only change.
2019-09-04 11:54:42 -04:00
Nick Mathewson
870874fec8 config: Make CLEAR with a nonempty value into a nonfatal assertion.
When we parse a CLEAR line (e.g., "/OrPort" or /OrPort blah blah"),
we always suppress the value, even if one exists.  That means that
the block of code was meant to handle CLEAR lines didn't actually do
anything, since we previously handled them the same way as with
other empty values.

Closes ticket 31529.
2019-09-04 11:28:21 -04:00
Nick Mathewson
539158f2be config: use ptrdiff_t for all field-offset members.
Previously we used int here, but it is more correct to use
ptrdiff_t.  (This never actually matters for our code in practice,
since the structure we are managing here never exceed INT_MAX in
size.)
2019-09-04 10:50:09 -04:00
David Goulet
34f3fcef40 Merge branch 'tor-github/pr/1290' 2019-09-04 10:33:49 -04:00
Nick Mathewson
46a3820652 Merge remote-tracking branch 'tor-github/pr/1270' 2019-09-04 09:52:35 -04:00
Nick Mathewson
c683896b7c Update routerset reset test to use new mgr API. 2019-09-04 08:42:34 -04:00
Nick Mathewson
17a870a64b Merge branch 'ticket31240v2_merged_2' into ticket31240v2_merged_2_merged 2019-09-04 08:41:42 -04:00
teor
9c798dd5a5
torerr: Fix a comment typo and update the comment for format_number_sigsafe()
Closes 31612.
2019-09-04 14:06:58 +10:00
teor
193c74faf9
Merge branch 'bug31571_041' into bug31571_master 2019-09-04 13:57:39 +10:00
teor
abe1f4f23e
Merge branch 'bug31571_040' into bug31571_041 2019-09-04 13:57:36 +10:00
teor
0cee6f498c
Merge branch 'bug31571_035' into bug31571_040 2019-09-04 13:57:31 +10:00
teor
a836dd2530
Merge branch 'maint-0.3.5' into bug31571_035 2019-09-04 13:57:15 +10:00
teor
f311d0676c backtrace: Check the return values of snprintf() and strncpy()
We can't use strlcat() or strlcpy() in torerr, because they are defined
in string/compat_string.h on some platforms, and string uses torerr.

Part of 31571.
2019-09-04 13:51:22 +10:00
George Kadianakis
7fa624537c Merge branch 'tor-github/pr/1269' 2019-09-03 17:11:25 +03:00
Nick Mathewson
a617001fd4 Merge remote-tracking branch 'tor-github/pr/1279' 2019-09-03 09:47:25 -04:00
Nick Mathewson
01bda9bed1 Merge branch 'maint-0.4.1' 2019-09-02 14:11:32 -04:00
Nick Mathewson
e3a458e441 Merge branch 'ticket12399_035' into maint-0.4.1 2019-09-02 14:11:18 -04:00
rl1987
05fa1689eb Change loglevel of message 'Hash of session info was not as expected' 2019-09-02 14:09:39 -04:00
Neel Chauhan
d22ed05dc0 Space out the arguments to the cell functions in rend_process_relay_cell() 2019-08-30 18:58:00 -04:00
teor
a52a5e0099
Merge branch 'maint-0.3.5' into maint-0.4.0 2019-08-30 23:33:01 +10:00
teor
1132dc9f75
Merge remote-tracking branch 'tor-github/pr/1181' into maint-0.3.5 2019-08-30 23:24:05 +10:00
teor
b66712d85b
Merge remote-tracking branch 'tor-github/pr/1117' into maint-0.3.5 2019-08-30 23:22:18 +10:00
teor
4662cbec7b
Merge remote-tracking branch 'tor-github/pr/1114' into maint-0.3.5 2019-08-30 23:20:59 +10:00
teor
c55591825f
torerr: Try harder to flush raw assert messages before process termination
Some platforms (macOS, maybe others?) can swallow the last write before an
abort. This issue is probably caused by a race condition between write
buffer cache flushing, and process termination. So we write an extra
newline, to make sure that the message always gets through.

Fixes bug 31571; bugfix on 0.3.5.1-alpha.
2019-08-30 21:51:11 +10:00
teor
65a1d86491
torerr: Log the Tor backtrace version when a raw assertion fails
Part of 31571.
2019-08-30 21:51:07 +10:00
teor
743bc0028b
backtrace: Log the Tor backtrace version whenever we log a backtrace
Previously, we just logged it in the crash handler.

Part of 31571.
2019-08-30 21:51:03 +10:00
teor
e2a7d08aa7
backtrace: Always set a backtrace Tor version
We want to report the tor version, even on platforms that don't have
backtrace support (like Android).

This commit stores the backtrace Tor version, regardless of USE_BACKTRACE.

Preparation for 31571.
2019-08-30 21:50:57 +10:00
Nick Mathewson
c281fa0da2 Describe clear_cfg_fn_t better. 2019-08-29 09:14:51 -04:00
David Goulet
960d989415 Merge branch 'tor-github/pr/1257' 2019-08-29 08:56:04 -04:00
David Goulet
7c99a4ddde Merge branch 'maint-0.4.1' 2019-08-29 08:55:58 -04:00
David Goulet
ff905f8e1e Merge branch 'tor-github/pr/1256' into maint-0.4.1 2019-08-29 08:55:31 -04:00
David Goulet
337b733cfc Merge branch 'tor-github/pr/1255' into maint-0.4.1 2019-08-29 08:55:27 -04:00
teor
063cf9cd23 string: macOS --enable-fragile-hardening uses safe string functions
Comment-only change.
2019-08-29 13:10:34 +10:00
teor
ec6fbf1ca6 nodelist: Use safe string functions in describe.c
Rewrite format_node_description() and router_get_verbose_nickname() to
use strlcpy() and strlcat(). The previous implementation used memcpy()
and pointer arithmetic, which was error-prone.

Closes ticket 31545. This is CID 1452819.
2019-08-29 13:09:08 +10:00
Nick Mathewson
1ef084c5fc test_confparse: verify that clearing a routerset sets it to NULL. 2019-08-28 12:28:17 -04:00
Nick Mathewson
f0c1f96adc Document configuration type definition functions for routerset_t
These functions are all used to implement the ROUTERSET_type_defn
object, which maps strings to and from routerset_t configuration
variables for the configuration module.
2019-08-28 12:23:36 -04:00
Nick Mathewson
2074fed664 Routerset config parsing: represent empty sets as NULL.
routerset_t has two representations of an empty routerset: NULL, and
a set containing no elements.  But some of our config code assumes
that empty routersets are represented as NULL.  So let's give it
what it assumes.

Fixes bug 31495. Bugfix on e16b90b88a76; but not in any released
Tor.
2019-08-28 11:53:28 -04:00
Nick Mathewson
04ab357df8 Remove extraneous "n" from comment in routerset.c 2019-08-28 11:39:31 -04:00
Nick Mathewson
b1d7ddfb02 Merge branch 'ticket31240v2' into ticket31240v2_merged_2 2019-08-28 09:46:59 -04:00
Nick Mathewson
a3e99c5f1e Add a test for clear_fn support in handling non-managed fields 2019-08-28 09:42:17 -04:00
Nick Mathewson
577e628743 Fix typo in a comment on config_mgr_get_obj_mutable() 2019-08-28 09:42:17 -04:00
Nick Mathewson
c967b5c9ba Add a test for dumping a compound configuration 2019-08-28 09:42:17 -04:00
Nick Mathewson
8db3859cc6 Simple tests for nested configuration formats
One test makes sure that the toplevel magic numbers are distinct.

One test makes sure that we can parse a configuration object
with two sub-objects.
2019-08-28 09:42:17 -04:00
Nick Mathewson
d9fe9f5ede Confmgr tests: test deprecations and abbreviations. 2019-08-28 09:42:17 -04:00
Nick Mathewson
e4162cdb38 Start on test cases for the multi-object feature of confmgr.
This test case, at this point, only constructs the confmgr object.
More code to come.
2019-08-28 09:42:17 -04:00
Nick Mathewson
cb5f8ace79 Tests for config_find_option_name()
Fix a bug in config_find_option_name() where it did not consider
the abbreviations table.
2019-08-28 09:42:17 -04:00
Nick Mathewson
aa3f0c4788 Add tests for variable-listing functions.
This discovered a bug related to an extra & in
config_mgr_list_deprecated_vars(): fix that.
2019-08-28 09:42:17 -04:00
Nick Mathewson
380d3ee168 Better explain config_clear_fn_t 2019-08-28 09:42:17 -04:00
Nick Mathewson
06da2c0d28 Document or_state_t.substates_ 2019-08-28 09:42:17 -04:00
Nick Mathewson
3af1cee6d9 Document or_options_t.subconfigs_ 2019-08-28 09:42:17 -04:00
Nick Mathewson
12d980027a document return lifespans for config_mgr_list_vars() 2019-08-28 09:42:17 -04:00
Nick Mathewson
9cfc811c37 Fix typo in comment about FallbackDir handling 2019-08-28 09:42:17 -04:00
Nick Mathewson
3a530ae535 Document types for config_get_changes() 2019-08-28 09:42:17 -04:00
Nick Mathewson
760d0c056f finish a comment explaining all_abbrevs 2019-08-28 09:42:17 -04:00
Nick Mathewson
638e58379a Partial support for multiplicity in configuration objects
A configuration manager, in addition to a top-level format object,
may now also know about a suite of sub-formats.  Top-level
configuration objects, in turn, may now have a suite of
sub-objects.
2019-08-28 09:40:53 -04:00
Nick Mathewson
38b770bbbb Make a config_suite_t type to hold multiple config sub-objects
Right now, it doesn't do anything; this patch is meant to make sure
that we're doing memory management correctly.
2019-08-28 09:40:53 -04:00
Nick Mathewson
47654d3249 Refactor config free logic to use a single path.
The right way to free a config object is now to wrap config_free(),
always.  Instead of creating an alternative free function, objects
should provide an alternative clear callback to free any fields that
the configuration manager doesn't manage.

This lets us simplify our code a little, and lets us extend the
confparse.c code to manage additional fields in config_free.
2019-08-28 09:40:53 -04:00
Nick Mathewson
3d1f9f583a Use special magic to enforce manager/object connection.
Every time we finalize a config manager, we now generate a new magic
number for it, so that we'll get an assertion failure if we ever try
to use an object with a different configuration manager than the one
that generated it.
2019-08-28 09:40:46 -04:00
George Kadianakis
78e084a12e Merge branch 'tor-github/pr/1267' 2019-08-27 11:47:46 +03:00
George Kadianakis
92a8573d22 Merge branch 'tor-github/pr/1258' 2019-08-27 11:45:18 +03:00
George Kadianakis
0d7f76d7ca Merge branch 'tor-github/pr/1234' 2019-08-27 11:44:13 +03:00
George Kadianakis
5782cee71d Merge branch 'tor-github/pr/1237' 2019-08-27 11:43:10 +03:00
Nick Mathewson
8af92b6577 test_address: parenthesize macro arguments.
It's good style to always add parentheses when using macro
arguments, in case somebody someday provides an argument that
contains an operator you don't expect, or causes the expression to
parse differently.
2019-08-26 20:03:16 -04:00
Nick Mathewson
5eca338107 In tests, make sure that "ri" is freed on all paths.
In Tor's tests, the tt_*() macros can call "goto done" on failure.
When that happens, we need to make sure that all of our allocated
memory still gets freed, or else Coverity will complain.
2019-08-26 20:03:11 -04:00
Neel Chauhan
c8e69e63f9 Add test for dirserv_router_has_valid_address() 2019-08-26 20:02:11 -04:00
Neel Chauhan
d9a7d47798 Check for private IPv6 addresses in dirserv_router_has_valid_address() 2019-08-26 18:21:56 -04:00
David Goulet
d819dfbded Merge branch 'tor-github/pr/1239' 2019-08-26 14:35:27 -04:00
David Goulet
cbe5f9571f test: Unit tests HS DoS torrc options
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:47 +03:00
David Goulet
461d231289 hs-v3: Refactor DoS cell extension parameters validation
Move everything to its own function in order to better log, document and tests
the introduction point validation process.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:47 +03:00
David Goulet
1c4607b132 hs-v3: Clarify comment in hs_dos.c
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:47 +03:00
David Goulet
292e9b0c00 hs-v3: Log info INTRO2 DoS defenses service values
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:47 +03:00
David Goulet
a98f5099c4 hs-v3: Missing intro circuit INTRO2 DoS enabled flag
When consensus changes, we also need to update the circuit INTRO2 defenses
enabled flag and not only the token bucket.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:47 +03:00
David Goulet
94a2221708 hs-v3: Privatize access to HS DoS consensus param
Remove the public functions returning the HS DoS consensus param or default
values as it is exclusively used internally now.

Rename the param_* variables to consensus_param_* for better code semantic.

Finally, make some private functions available to unit tests.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00
David Goulet
184c76e339 hs-v3: Cleanup usage of consensus param in hs_dos.c
This commit makes it that the hs_dos.c file only uses the consensus parameter
variables set when we initialize and when the consensus changes.

There is no need to call each time networkstatus_get_param(), which is
expensive, when we want access to a consensus value.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00
David Goulet
82639a8c7b hs-v3: Move to hs_dos.c INTRO2 defenses initialization
A bit cleaner especially that the next commit(s) will make the consensus param
interface private to hs_dos.c so we expose as little as we can outside of the
subsystem.

Part of #30924

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00