[tor-bugs] #23643 [Core Tor/Tor]: Type-check struct members that are passed to confparse

Tor Bug Tracker & Wiki blackhole at torproject.org
Tue Sep 26 16:06:59 UTC 2017


#23643: Type-check struct members that are passed to confparse
--------------------------+------------------------------------
 Reporter:  nickm         |          Owner:  nickm
     Type:  defect        |         Status:  merge_ready
 Priority:  Medium        |      Milestone:  Tor: 0.3.2.x-final
Component:  Core Tor/Tor  |        Version:
 Severity:  Normal        |     Resolution:
 Keywords:                |  Actual Points:
Parent ID:                |         Points:
 Reviewer:  catalyst      |        Sponsor:
--------------------------+------------------------------------
Changes (by catalyst):

 * status:  needs_review => merge_ready


Comment:

 Looks good to me!

 Feel free to merge as is, but here are a few nitpicks that will hopefully
 improve clarity:
 * In the changes file, maybe say "any type mismatches between the C type
 representing a configuration variable and the C type the data-driven
 parser uses to store a value there"? The current wording implies that it
 checks for user errors in a config file.
 * Maybe mention in the comment for `CONF_CHECK_VAR_TYPE()` that the type
 checking technique works because a mismatch violates the type
 compatibility constraint on simple assignment and requires a diagnostic?
 (That way it's more clear that a conforming compiler will produce some
 sort of warning and we're not relying on a specific compiler's
 enthusiastic warning behavior.)
 * Maybe use a macro, possibly named `DUMMY_TYPECHECK_INSTANCE`, to declare
 the dummy structs?
 * The `int *UINT; /* yes, really. */` comment could be more clear,
 possibly `/* yes, config_assign_value() bounds-checks "UINT" values as
 0..INT_MAX */`?
 * The non-unit-test variant of `CONF_TEST_MEMBERS()` should use the same
 parameter names as the other unit-test variant.
 * Removal of the `const` qualifier for `TransProxyType` is not documented
 in the commit message.
 Sorry about the length; this is a tricky technique and I would like us to
 make it as clear as possible what's going on.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/23643#comment:11>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list