Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
a18f04e8
Commit
a18f04e8
authored
May 24, 2012
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed buffer overrun in spdylay_pq_push
parent
31ff69ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
lib/spdylay_pq.c
lib/spdylay_pq.c
+3
-2
tests/spdylay_pq_test.c
tests/spdylay_pq_test.c
+14
-1
No files found.
lib/spdylay_pq.c
View file @
a18f04e8
...
...
@@ -27,7 +27,7 @@
int
spdylay_pq_init
(
spdylay_pq
*
pq
,
spdylay_compar
compar
)
{
pq
->
capacity
=
4096
;
pq
->
q
=
malloc
(
pq
->
capacity
);
pq
->
q
=
malloc
(
pq
->
capacity
*
sizeof
(
void
*
)
);
if
(
pq
->
q
==
NULL
)
{
return
SPDYLAY_ERR_NOMEM
;
}
...
...
@@ -65,7 +65,8 @@ static void bubble_up(spdylay_pq *pq, size_t index)
int
spdylay_pq_push
(
spdylay_pq
*
pq
,
void
*
item
)
{
if
(
pq
->
capacity
<=
pq
->
length
)
{
void
*
nq
=
realloc
(
pq
->
q
,
pq
->
capacity
*
2
);
void
*
nq
;
nq
=
realloc
(
pq
->
q
,
(
pq
->
capacity
*
2
)
*
sizeof
(
void
*
));
if
(
nq
==
NULL
)
{
return
SPDYLAY_ERR_NOMEM
;
}
...
...
tests/spdylay_pq_test.c
View file @
a18f04e8
...
...
@@ -35,6 +35,7 @@ static int pq_compar(const void *lhs, const void *rhs)
void
test_spdylay_pq
(
void
)
{
int
i
;
spdylay_pq
pq
;
spdylay_pq_init
(
&
pq
,
pq_compar
);
CU_ASSERT
(
spdylay_pq_empty
(
&
pq
));
...
...
@@ -60,7 +61,19 @@ void test_spdylay_pq(void)
spdylay_pq_pop
(
&
pq
);
CU_ASSERT
(
spdylay_pq_empty
(
&
pq
));
CU_ASSERT
(
0
==
spdylay_pq_size
(
&
pq
));
CU_ASSERT
(
0
==
spdylay_pq_top
(
&
pq
));
CU_ASSERT
(
NULL
==
spdylay_pq_top
(
&
pq
));
/* Add bunch of entry to see realloc works */
for
(
i
=
0
;
i
<
10000
;
++
i
)
{
CU_ASSERT
(
0
==
spdylay_pq_push
(
&
pq
,
(
void
*
)
"foo"
));
CU_ASSERT
(
i
+
1
==
spdylay_pq_size
(
&
pq
));
}
for
(
i
=
10000
;
i
>
0
;
--
i
)
{
CU_ASSERT
(
NULL
!=
spdylay_pq_top
(
&
pq
));
spdylay_pq_pop
(
&
pq
);
CU_ASSERT
(
i
-
1
==
spdylay_pq_size
(
&
pq
));
}
spdylay_pq_free
(
&
pq
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment