Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Core
Tor
Commits
0e2834a3
Unverified
Commit
0e2834a3
authored
5 years ago
by
teor
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'tor-github/pr/1348' into maint-0.3.5
parents
d2e4262e
0614f839
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changes/bug31408
+5
-0
5 additions, 0 deletions
changes/bug31408
src/lib/fs/conffile.c
+6
-4
6 additions, 4 deletions
src/lib/fs/conffile.c
src/test/test_config.c
+68
-0
68 additions, 0 deletions
src/test/test_config.c
with
79 additions
and
4 deletions
changes/bug31408
0 → 100644
+
5
−
0
View file @
0e2834a3
o Major bugfixes (torrc):
- Stop ignoring torrc options after an %include directive, when the
included directory ends with a file that does not contain any config
options. (But does contain comments or whitespace.)
Fixes bug 31408; bugfix on 0.3.1.1-alpha.
This diff is collapsed.
Click to expand it.
src/lib/fs/conffile.c
+
6
−
4
View file @
0e2834a3
...
...
@@ -153,16 +153,18 @@ config_process_include(const char *path, int recursion_level, int extended,
int
rv
=
-
1
;
SMARTLIST_FOREACH_BEGIN
(
config_files
,
const
char
*
,
config_file
)
{
config_line_t
*
included_config
=
NULL
;
config_line_t
*
included_config_last
=
NULL
;
if
(
config_get_included_config
(
config_file
,
recursion_level
,
extended
,
&
included_config
,
list
_last
,
&
included_config
,
&
included_config
_last
,
opened_lst
)
<
0
)
{
goto
done
;
}
*
next
=
included_config
;
if
(
*
list_last
)
next
=
&
(
*
list_last
)
->
next
;
if
(
included_config_last
)
{
next
=
&
included_config_last
->
next
;
*
list_last
=
included_config_last
;
}
}
SMARTLIST_FOREACH_END
(
config_file
);
*
list
=
ret_list
;
rv
=
0
;
...
...
This diff is collapsed.
Click to expand it.
src/test/test_config.c
+
68
−
0
View file @
0e2834a3
...
...
@@ -5286,6 +5286,73 @@ test_config_include_folder_order(void *data)
tor_free
(
dir
);
}
static
void
test_config_include_blank_file_last
(
void
*
data
)
{
(
void
)
data
;
config_line_t
*
result
=
NULL
;
char
*
torrcd
=
NULL
;
char
*
path
=
NULL
;
char
*
dir
=
tor_strdup
(
get_fname
(
"test_include_blank_file_last"
));
tt_ptr_op
(
dir
,
OP_NE
,
NULL
);
#ifdef _WIN32
tt_int_op
(
mkdir
(
dir
),
OP_EQ
,
0
);
#else
tt_int_op
(
mkdir
(
dir
,
0700
),
OP_EQ
,
0
);
#endif
tor_asprintf
(
&
torrcd
,
"%s"
PATH_SEPARATOR
"%s"
,
dir
,
"torrc.d"
);
#ifdef _WIN32
tt_int_op
(
mkdir
(
torrcd
),
OP_EQ
,
0
);
#else
tt_int_op
(
mkdir
(
torrcd
,
0700
),
OP_EQ
,
0
);
#endif
tor_asprintf
(
&
path
,
"%s"
PATH_SEPARATOR
"%s"
,
torrcd
,
"aa_1st"
);
tt_int_op
(
write_str_to_file
(
path
,
"Test 1
\n
"
,
0
),
OP_EQ
,
0
);
tor_free
(
path
);
tor_asprintf
(
&
path
,
"%s"
PATH_SEPARATOR
"%s"
,
torrcd
,
"bb_2nd"
);
tt_int_op
(
write_str_to_file
(
path
,
"Test 2
\n
"
,
0
),
OP_EQ
,
0
);
tor_free
(
path
);
tor_asprintf
(
&
path
,
"%s"
PATH_SEPARATOR
"%s"
,
torrcd
,
"cc_comment"
);
tt_int_op
(
write_str_to_file
(
path
,
"# comment only
\n
"
,
0
),
OP_EQ
,
0
);
tor_free
(
path
);
char
torrc_contents
[
1000
];
tor_snprintf
(
torrc_contents
,
sizeof
(
torrc_contents
),
"%%include %s
\n
"
"Test 3
\n
"
,
torrcd
);
int
include_used
;
tt_int_op
(
config_get_lines_include
(
torrc_contents
,
&
result
,
0
,
&
include_used
,
NULL
),
OP_EQ
,
0
);
tt_ptr_op
(
result
,
OP_NE
,
NULL
);
tt_int_op
(
include_used
,
OP_EQ
,
1
);
int
len
=
0
;
config_line_t
*
next
;
for
(
next
=
result
;
next
!=
NULL
;
next
=
next
->
next
)
{
char
expected
[
10
];
tor_snprintf
(
expected
,
sizeof
(
expected
),
"%d"
,
len
+
1
);
tt_str_op
(
next
->
key
,
OP_EQ
,
"Test"
);
tt_str_op
(
next
->
value
,
OP_EQ
,
expected
);
len
++
;
}
tt_int_op
(
len
,
OP_EQ
,
3
);
done:
config_free_lines
(
result
);
tor_free
(
torrcd
);
tor_free
(
path
);
tor_free
(
dir
);
}
static
void
test_config_include_path_syntax
(
void
*
data
)
{
...
...
@@ -5848,6 +5915,7 @@ struct testcase_t config_tests[] = {
CONFIG_TEST
(
include_recursion_before_after
,
0
),
CONFIG_TEST
(
include_recursion_after_only
,
0
),
CONFIG_TEST
(
include_folder_order
,
0
),
CONFIG_TEST
(
include_blank_file_last
,
0
),
CONFIG_TEST
(
include_path_syntax
,
0
),
CONFIG_TEST
(
include_not_processed
,
0
),
CONFIG_TEST
(
include_has_include
,
0
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment