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
1bcececd
Commit
1bcececd
authored
6 years ago
by
rl1987
Committed by
Nick Mathewson
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix CID 1442277
parent
41e3c760
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changes/bug28989
+5
-0
5 additions, 0 deletions
changes/bug28989
src/test/test_hs_service.c
+32
-0
32 additions, 0 deletions
src/test/test_hs_service.c
with
37 additions
and
0 deletions
changes/bug28989
0 → 100644
+
5
−
0
View file @
1bcececd
o Minor bugfixes (unit tests):
- Instead of relying on hs_free_all() to clean up all onion service
objects we created in test_build_descriptors(), deallocate
them one by one. This lets Coverity know that we are not leaking memory
here and fixes CID 1442277. Fixes bug 28989; bugfix on 0.3.5.1-alpha.
This diff is collapsed.
Click to expand it.
src/test/test_hs_service.c
+
32
−
0
View file @
1bcececd
...
...
@@ -289,6 +289,20 @@ helper_create_service(void)
return
service
;
}
/* Helper: Deallocate a given service object, its child objects and
* remove it from onion service map.
* */
static
void
helper_destroy_service
(
hs_service_t
*
service
)
{
if
(
!
service
)
return
;
remove_service
(
get_hs_service_map
(),
service
);
hs_service_free
(
service
);
}
/* Helper: Return a newly allocated service object with clients. */
static
hs_service_t
*
helper_create_service_with_clients
(
int
num_clients
)
...
...
@@ -1626,6 +1640,7 @@ test_build_descriptors(void *arg)
{
int
ret
;
time_t
now
=
time
(
NULL
);
hs_service_t
*
last_service
=
NULL
;
(
void
)
arg
;
...
...
@@ -1650,6 +1665,7 @@ test_build_descriptors(void *arg)
* is disabled. */
{
hs_service_t
*
service
=
helper_create_service
();
last_service
=
service
;
service_descriptor_free
(
service
->
desc_current
);
service
->
desc_current
=
NULL
;
...
...
@@ -1660,12 +1676,16 @@ test_build_descriptors(void *arg)
hs_desc_superencrypted_data_t
*
superencrypted
;
superencrypted
=
&
service
->
desc_current
->
desc
->
superencrypted_data
;
tt_int_op
(
smartlist_len
(
superencrypted
->
clients
),
OP_EQ
,
16
);
helper_destroy_service
(
service
);
last_service
=
NULL
;
}
/* Generate a valid number of fake auth clients when the number of
* clients is zero. */
{
hs_service_t
*
service
=
helper_create_service_with_clients
(
0
);
last_service
=
service
;
service_descriptor_free
(
service
->
desc_current
);
service
->
desc_current
=
NULL
;
...
...
@@ -1673,12 +1693,16 @@ test_build_descriptors(void *arg)
hs_desc_superencrypted_data_t
*
superencrypted
;
superencrypted
=
&
service
->
desc_current
->
desc
->
superencrypted_data
;
tt_int_op
(
smartlist_len
(
superencrypted
->
clients
),
OP_EQ
,
16
);
helper_destroy_service
(
service
);
last_service
=
NULL
;
}
/* Generate a valid number of fake auth clients when the number of
* clients is not a multiple of 16. */
{
hs_service_t
*
service
=
helper_create_service_with_clients
(
20
);
last_service
=
service
;
service_descriptor_free
(
service
->
desc_current
);
service
->
desc_current
=
NULL
;
...
...
@@ -1686,12 +1710,16 @@ test_build_descriptors(void *arg)
hs_desc_superencrypted_data_t
*
superencrypted
;
superencrypted
=
&
service
->
desc_current
->
desc
->
superencrypted_data
;
tt_int_op
(
smartlist_len
(
superencrypted
->
clients
),
OP_EQ
,
32
);
helper_destroy_service
(
service
);
last_service
=
NULL
;
}
/* Do not generate any fake desc client when the number of clients is
* a multiple of 16 but not zero. */
{
hs_service_t
*
service
=
helper_create_service_with_clients
(
32
);
last_service
=
service
;
service_descriptor_free
(
service
->
desc_current
);
service
->
desc_current
=
NULL
;
...
...
@@ -1699,9 +1727,13 @@ test_build_descriptors(void *arg)
hs_desc_superencrypted_data_t
*
superencrypted
;
superencrypted
=
&
service
->
desc_current
->
desc
->
superencrypted_data
;
tt_int_op
(
smartlist_len
(
superencrypted
->
clients
),
OP_EQ
,
32
);
helper_destroy_service
(
service
);
last_service
=
NULL
;
}
done:
helper_destroy_service
(
last_service
);
hs_free_all
();
}
...
...
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