[tor-bugs] #33993 [Applications/rbm]: In input_files, target, target_prepend, target_append are silently ignored if they are not an array

Tor Bug Tracker & Wiki blackhole at torproject.org
Mon Apr 27 11:37:05 UTC 2020


#33993: In input_files, target, target_prepend, target_append are silently ignored
if they are not an array
----------------------------------+--------------------------------
 Reporter:  boklm                 |          Owner:  boklm
     Type:  defect                |         Status:  needs_revision
 Priority:  Medium                |      Milestone:
Component:  Applications/rbm      |        Version:
 Severity:  Normal                |     Resolution:
 Keywords:  TorBrowserTeam202004  |  Actual Points:
Parent ID:                        |         Points:
 Reviewer:                        |        Sponsor:
----------------------------------+--------------------------------
Changes (by gk):

 * keywords:  TorBrowserTeam202004R => TorBrowserTeam202004
 * status:  needs_review => needs_revision


Comment:

 Replying to [comment:3 boklm]:
 > Replying to [comment:2 gk]:
 > > You have
 > > {{{
 > >             if (ref $input_file->{target} eq 'ARRAY') {
 > >                 $input_file->{target} = process_template_opt($project,
 > >                                             $input_file->{target},
 $options);
 > >             } else {
 > >                 $input_file->{target} = $config->{run}{target};
 > >             }
 > >             if (ref $input_file->{target_prepend} eq 'ARRAY') {
 > >                 $input_file->{target} = [ @{
 process_template_opt($project,
 > >
 $input_file->{target_prepend},
 > >                                                $options) },
 > >                                           @{$input_file->{target}} ];
 > >             }
 > >             if (ref $input_file->{target_append} eq 'ARRAY') {
 > >                 $input_file->{target} = [ @{$input_file->{target}},
 > >                                           @{
 process_template_opt($project,
 > >
 $input_file->{target_append},
 > >                                                $options) } ];
 > >             }
 > > }}}
 > > below the patch. Two questions:
 > >
 > > 1) Do we still need all the array checks in that one given that we
 already checked for arrays in the patch and exit with an error in case the
 condition is not met?
 >
 > Before entering in this part, we know that at least one of `target`,
 `target_append` and `target_prepend` is defined (more exactly, defined to
 a true value, so empty string would be ignored). The `foreach/if` added by
 the patch is checking that if it is defined, it is defined as an array.
 >
 > After this we know that at least one is an array, but we still don't
 know which one(s), so the following `if`s are still needed. Although they
 could check that it is defined instead of checking that it is an array. I
 can change that if you think that's better.

 Please do.

 > >
 > > 2) How would the `else` clause still be called given that we are now
 bailing out earlier if `target` is no array?
 >
 > The `else` clause is called if `target_append` or `target_prepend` is
 defined (as an array), but `target` is not defined.

 Thanks.

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


More information about the tor-bugs mailing list