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
fbf1c5ee
Commit
fbf1c5ee
authored
13 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'public/bug4230' into maint-0.2.2
parents
841247a5
e1c6431e
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/bug4230
+5
-0
5 additions, 0 deletions
changes/bug4230
src/common/container.c
+14
-5
14 additions, 5 deletions
src/common/container.c
with
19 additions
and
5 deletions
changes/bug4230
0 → 100644
+
5
−
0
View file @
fbf1c5ee
o Minor bugfixes:
- Resolve an integer overflow bug in smartlist_ensure_capacity.
Fixes bug 4230; bugfix on Tor 0.1.0.1-rc. Based on a patch by
Mansour Moufid.
This diff is collapsed.
Click to expand it.
src/common/container.c
+
14
−
5
View file @
fbf1c5ee
...
...
@@ -62,13 +62,22 @@ smartlist_clear(smartlist_t *sl)
static
INLINE
void
smartlist_ensure_capacity
(
smartlist_t
*
sl
,
int
size
)
{
#if SIZEOF_SIZE_T > SIZEOF_INT
#define MAX_CAPACITY (INT_MAX)
#else
#define MAX_CAPACITY (int)((SIZE_MAX / (sizeof(void*))))
#endif
if
(
size
>
sl
->
capacity
)
{
int
higher
=
sl
->
capacity
*
2
;
while
(
size
>
higher
)
higher
*=
2
;
tor_assert
(
higher
>
0
);
/* detect overflow */
int
higher
=
sl
->
capacity
;
if
(
PREDICT_UNLIKELY
(
size
>
MAX_CAPACITY
/
2
))
{
tor_assert
(
size
<=
MAX_CAPACITY
);
higher
=
MAX_CAPACITY
;
}
else
{
while
(
size
>
higher
)
higher
*=
2
;
}
sl
->
capacity
=
higher
;
sl
->
list
=
tor_realloc
(
sl
->
list
,
sizeof
(
void
*
)
*
sl
->
capacity
);
sl
->
list
=
tor_realloc
(
sl
->
list
,
sizeof
(
void
*
)
*
((
size_t
)
sl
->
capacity
)
)
;
}
}
...
...
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