Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Benjamin J. Thompson
Tor
Commits
b0646cc1
Commit
b0646cc1
authored
12 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/maint-0.2.2' into maint-0.2.3
parents
2ecee3fc
cb693ef5
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/bug7191
+5
-0
5 additions, 0 deletions
changes/bug7191
src/common/container.c
+22
-1
22 additions, 1 deletion
src/common/container.c
src/test/test_containers.c
+36
-0
36 additions, 0 deletions
src/test/test_containers.c
with
63 additions
and
1 deletion
changes/bug7191
0 → 100644
+
5
−
0
View file @
b0646cc1
o Major bugfixes:
- Fix a denial of service attack by which any directory authority
could crash all the others, or by which a single v2 directory
authority could crash everybody downloading v2 directory
information. Fixes bug 7191; bugfix on 0.2.0.10-alpha.
This diff is collapsed.
Click to expand it.
src/common/container.c
+
22
−
1
View file @
b0646cc1
...
...
@@ -571,7 +571,28 @@ smartlist_bsearch_idx(const smartlist_t *sl, const void *key,
int
(
*
compare
)(
const
void
*
key
,
const
void
**
member
),
int
*
found_out
)
{
int
hi
=
smartlist_len
(
sl
)
-
1
,
lo
=
0
,
cmp
,
mid
;
const
int
len
=
smartlist_len
(
sl
);
int
hi
,
lo
,
cmp
,
mid
;
if
(
len
==
0
)
{
*
found_out
=
0
;
return
0
;
}
else
if
(
len
==
1
)
{
cmp
=
compare
(
key
,
(
const
void
**
)
&
sl
->
list
[
0
]);
if
(
cmp
==
0
)
{
*
found_out
=
1
;
return
0
;
}
else
if
(
cmp
<
0
)
{
*
found_out
=
0
;
return
0
;
}
else
{
*
found_out
=
0
;
return
1
;
}
}
hi
=
smartlist_len
(
sl
)
-
1
;
lo
=
0
;
while
(
lo
<=
hi
)
{
mid
=
(
lo
+
hi
)
/
2
;
...
...
This diff is collapsed.
Click to expand it.
src/test/test_containers.c
+
36
−
0
View file @
b0646cc1
...
...
@@ -16,6 +16,15 @@ _compare_strs(const void **a, const void **b)
return
strcmp
(
s1
,
s2
);
}
/** Helper: return a tristate based on comparing the strings in <b>a</b> and
* *<b>b</b>. */
static
int
compare_strs_for_bsearch_
(
const
void
*
a
,
const
void
**
b
)
{
const
char
*
s1
=
a
,
*
s2
=
*
b
;
return
strcmp
(
s1
,
s2
);
}
/** Helper: return a tristate based on comparing the strings in *<b>a</b> and
* *<b>b</b>, excluding a's first character, and ignoring case. */
static
int
...
...
@@ -204,6 +213,8 @@ test_container_smartlist_strings(void)
/* Test bsearch_idx */
{
int
f
;
smartlist_t
*
tmp
=
NULL
;
test_eq
(
0
,
smartlist_bsearch_idx
(
sl
,
" aaa"
,
_compare_without_first_ch
,
&
f
));
test_eq
(
f
,
0
);
test_eq
(
0
,
smartlist_bsearch_idx
(
sl
,
" and"
,
_compare_without_first_ch
,
&
f
));
...
...
@@ -216,6 +227,31 @@ test_container_smartlist_strings(void)
test_eq
(
f
,
0
);
test_eq
(
7
,
smartlist_bsearch_idx
(
sl
,
" zzzz"
,
_compare_without_first_ch
,
&
f
));
test_eq
(
f
,
0
);
/* Test trivial cases for list of length 0 or 1 */
tmp
=
smartlist_create
();
test_eq
(
0
,
smartlist_bsearch_idx
(
tmp
,
"foo"
,
compare_strs_for_bsearch_
,
&
f
));
test_eq
(
f
,
0
);
smartlist_insert
(
tmp
,
0
,
(
void
*
)(
"bar"
));
test_eq
(
1
,
smartlist_bsearch_idx
(
tmp
,
"foo"
,
compare_strs_for_bsearch_
,
&
f
));
test_eq
(
f
,
0
);
test_eq
(
0
,
smartlist_bsearch_idx
(
tmp
,
"aaa"
,
compare_strs_for_bsearch_
,
&
f
));
test_eq
(
f
,
0
);
test_eq
(
0
,
smartlist_bsearch_idx
(
tmp
,
"bar"
,
compare_strs_for_bsearch_
,
&
f
));
test_eq
(
f
,
1
);
/* ... and one for length 2 */
smartlist_insert
(
tmp
,
1
,
(
void
*
)(
"foo"
));
test_eq
(
1
,
smartlist_bsearch_idx
(
tmp
,
"foo"
,
compare_strs_for_bsearch_
,
&
f
));
test_eq
(
f
,
1
);
test_eq
(
2
,
smartlist_bsearch_idx
(
tmp
,
"goo"
,
compare_strs_for_bsearch_
,
&
f
));
test_eq
(
f
,
0
);
smartlist_free
(
tmp
);
}
/* Test reverse() and pop_last() */
...
...
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