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

Tor Bug Tracker & Wiki blackhole at torproject.org
Mon Sep 25 20:42:57 UTC 2017


#23643: Type-check struct members that are passed to confparse
--------------------------+------------------------------------
 Reporter:  nickm         |          Owner:  nickm
     Type:  defect        |         Status:  needs_revision
 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:
--------------------------+------------------------------------

Comment (by catalyst):

 Something like this?

 {{{
 union dummyaddrs {
         char **a_str;
         int *a_int;
         double *a_double;
         const char **a_cstr;
 };

 typedef struct {
         const char *name;
         int typenum;
         union dummyaddrs _;
 } config_var_t;

 typedef struct {
         char *foostr;
         int fooint;
         const char *foocstr;
 } some_opts;

 #define optline(name, tnum, checktype) \
         { #name, tnum, { .checktype = &opts0.name } }

 static some_opts opts0;

 config_var_t cvars[];

 config_var_t cvars[] = {
         optline(fooint, 0, a_int),
         optline(foostr, 0, a_str),
         optline(foocstr, 0, a_cstr),
 };
 }}}

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


More information about the tor-bugs mailing list