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
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
orbea
Tor
Commits
e78a7450
Commit
e78a7450
authored
4 years ago
by
Alexander Hansen Færøy
Browse files
Options
Downloads
Plain Diff
Merge branch 'maint-0.4.2' into maint-0.4.3
parents
3b8bf743
4e684c86
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/bug40076
+5
-0
5 additions, 0 deletions
changes/bug40076
src/lib/buf/buffers.c
+2
-0
2 additions, 0 deletions
src/lib/buf/buffers.c
src/test/test_buffers.c
+64
-0
64 additions, 0 deletions
src/test/test_buffers.c
with
71 additions
and
0 deletions
changes/bug40076
0 → 100644
+
5
−
0
View file @
e78a7450
o Minor bugfixes (correctness, buffers):
- Fix a correctness bug that could cause an assertion failure if we ever
tried using the buf_move_all() function with an empty input.
As far as we know, no released versions of Tor do this.
Fixes bug 40076; bugfix on 0.3.3.1-alpha.
This diff is collapsed.
Click to expand it.
src/lib/buf/buffers.c
+
2
−
0
View file @
e78a7450
...
...
@@ -692,6 +692,8 @@ buf_move_all(buf_t *buf_out, buf_t *buf_in)
tor_assert
(
buf_out
);
if
(
!
buf_in
)
return
;
if
(
buf_datalen
(
buf_in
)
==
0
)
return
;
if
(
BUG
(
buf_out
->
datalen
>=
INT_MAX
||
buf_in
->
datalen
>=
INT_MAX
))
return
;
if
(
BUG
(
buf_out
->
datalen
>=
INT_MAX
-
buf_in
->
datalen
))
...
...
This diff is collapsed.
Click to expand it.
src/test/test_buffers.c
+
64
−
0
View file @
e78a7450
...
...
@@ -302,6 +302,69 @@ test_buffer_pullup(void *arg)
tor_free
(
tmp
);
}
static
void
test_buffers_move_all
(
void
*
arg
)
{
(
void
)
arg
;
buf_t
*
input
=
buf_new
();
buf_t
*
output
=
buf_new
();
char
*
s
=
NULL
;
/* Move from empty buffer to nonempty buffer. (This is a regression test for
* #40076) */
buf_add
(
output
,
"abc"
,
3
);
buf_assert_ok
(
input
);
buf_assert_ok
(
output
);
buf_move_all
(
output
,
input
);
buf_assert_ok
(
input
);
buf_assert_ok
(
output
);
tt_int_op
(
buf_datalen
(
output
),
OP_EQ
,
3
);
s
=
buf_extract
(
output
,
NULL
);
tt_str_op
(
s
,
OP_EQ
,
"abc"
);
buf_free
(
output
);
buf_free
(
input
);
tor_free
(
s
);
/* Move from empty to empty. */
output
=
buf_new
();
input
=
buf_new
();
buf_move_all
(
output
,
input
);
buf_assert_ok
(
input
);
buf_assert_ok
(
output
);
tt_int_op
(
buf_datalen
(
output
),
OP_EQ
,
0
);
buf_free
(
output
);
buf_free
(
input
);
/* Move from nonempty to empty. */
output
=
buf_new
();
input
=
buf_new
();
buf_add
(
input
,
"longstanding bugs"
,
17
);
buf_move_all
(
output
,
input
);
buf_assert_ok
(
input
);
buf_assert_ok
(
output
);
s
=
buf_extract
(
output
,
NULL
);
tt_str_op
(
s
,
OP_EQ
,
"longstanding bugs"
);
buf_free
(
output
);
buf_free
(
input
);
tor_free
(
s
);
/* Move from nonempty to nonempty. */
output
=
buf_new
();
input
=
buf_new
();
buf_add
(
output
,
"the start of"
,
12
);
buf_add
(
input
,
" a string"
,
9
);
buf_move_all
(
output
,
input
);
buf_assert_ok
(
input
);
buf_assert_ok
(
output
);
s
=
buf_extract
(
output
,
NULL
);
tt_str_op
(
s
,
OP_EQ
,
"the start of a string"
);
done:
buf_free
(
output
);
buf_free
(
input
);
tor_free
(
s
);
}
static
void
test_buffer_copy
(
void
*
arg
)
{
...
...
@@ -799,6 +862,7 @@ struct testcase_t buffer_tests[] = {
{
"basic"
,
test_buffers_basic
,
TT_FORK
,
NULL
,
NULL
},
{
"copy"
,
test_buffer_copy
,
TT_FORK
,
NULL
,
NULL
},
{
"pullup"
,
test_buffer_pullup
,
TT_FORK
,
NULL
,
NULL
},
{
"move_all"
,
test_buffers_move_all
,
0
,
NULL
,
NULL
},
{
"startswith"
,
test_buffer_peek_startswith
,
0
,
NULL
,
NULL
},
{
"allocation_tracking"
,
test_buffer_allocation_tracking
,
TT_FORK
,
NULL
,
NULL
},
...
...
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