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
52b74144
Commit
52b74144
authored
Apr 30, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 0 size malloc, part 2
parent
1b79114d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
14 deletions
+54
-14
lib/nghttp2_frame.c
lib/nghttp2_frame.c
+31
-4
lib/nghttp2_helper.c
lib/nghttp2_helper.c
+7
-1
lib/nghttp2_session.c
lib/nghttp2_session.c
+16
-9
No files found.
lib/nghttp2_frame.c
View file @
52b74144
...
...
@@ -515,11 +515,18 @@ int nghttp2_frame_unpack_settings_payload(nghttp2_settings *frame,
{
size_t
payloadlen
=
niv
*
sizeof
(
nghttp2_settings_entry
);
frame
->
iv
=
malloc
(
payloadlen
);
if
(
frame
->
iv
==
NULL
)
{
return
NGHTTP2_ERR_NOMEM
;
if
(
niv
==
0
)
{
frame
->
iv
=
NULL
;
}
else
{
frame
->
iv
=
malloc
(
payloadlen
);
if
(
frame
->
iv
==
NULL
)
{
return
NGHTTP2_ERR_NOMEM
;
}
memcpy
(
frame
->
iv
,
iv
,
payloadlen
);
}
memcpy
(
frame
->
iv
,
iv
,
payloadlen
);
frame
->
niv
=
niv
;
return
0
;
}
...
...
@@ -537,15 +544,27 @@ int nghttp2_frame_unpack_settings_payload2(nghttp2_settings_entry **iv_ptr,
size_t
payloadlen
)
{
size_t
i
;
*
niv_ptr
=
payloadlen
/
NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH
;
if
(
*
niv_ptr
==
0
)
{
*
iv_ptr
=
NULL
;
return
0
;
}
*
iv_ptr
=
malloc
((
*
niv_ptr
)
*
sizeof
(
nghttp2_settings_entry
));
if
(
*
iv_ptr
==
NULL
)
{
return
NGHTTP2_ERR_NOMEM
;
}
for
(
i
=
0
;
i
<
*
niv_ptr
;
++
i
)
{
size_t
off
=
i
*
NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH
;
nghttp2_frame_unpack_settings_entry
(
&
(
*
iv_ptr
)[
i
],
&
payload
[
off
]);
}
return
0
;
}
...
...
@@ -829,11 +848,19 @@ nghttp2_settings_entry* nghttp2_frame_iv_copy(const nghttp2_settings_entry *iv,
{
nghttp2_settings_entry
*
iv_copy
;
size_t
len
=
niv
*
sizeof
(
nghttp2_settings_entry
);
if
(
len
==
0
)
{
return
NULL
;
}
iv_copy
=
malloc
(
len
);
if
(
iv_copy
==
NULL
)
{
return
NULL
;
}
memcpy
(
iv_copy
,
iv
,
len
);
return
iv_copy
;
}
...
...
lib/nghttp2_helper.c
View file @
52b74144
...
...
@@ -74,7 +74,13 @@ int nghttp2_reserve_buffer(uint8_t **buf_ptr, size_t *buflen_ptr,
void
*
nghttp2_memdup
(
const
void
*
src
,
size_t
n
)
{
void
*
dest
=
malloc
(
n
);
void
*
dest
;
if
(
n
==
0
)
{
return
NULL
;
}
dest
=
malloc
(
n
);
if
(
dest
==
NULL
)
{
return
NULL
;
}
...
...
lib/nghttp2_session.c
View file @
52b74144
...
...
@@ -4814,13 +4814,15 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
varlen
=
iframe
->
frame
.
hd
.
length
-
8
;
iframe
->
raw_lbuf
=
malloc
(
varlen
);
if
(
varlen
>
0
)
{
iframe
->
raw_lbuf
=
malloc
(
varlen
);
if
(
iframe
->
raw_lbuf
==
NULL
)
{
return
NGHTTP2_ERR_NOMEM
;
}
if
(
iframe
->
raw_lbuf
==
NULL
)
{
return
NGHTTP2_ERR_NOMEM
;
}
nghttp2_buf_wrap_init
(
&
iframe
->
lbuf
,
iframe
->
raw_lbuf
,
varlen
);
nghttp2_buf_wrap_init
(
&
iframe
->
lbuf
,
iframe
->
raw_lbuf
,
varlen
);
}
busy
=
1
;
...
...
@@ -5528,10 +5530,15 @@ int nghttp2_session_add_settings(nghttp2_session *session, uint8_t flags,
if
(
frame
==
NULL
)
{
return
NGHTTP2_ERR_NOMEM
;
}
iv_copy
=
nghttp2_frame_iv_copy
(
iv
,
niv
);
if
(
iv_copy
==
NULL
)
{
free
(
frame
);
return
NGHTTP2_ERR_NOMEM
;
if
(
niv
>
0
)
{
iv_copy
=
nghttp2_frame_iv_copy
(
iv
,
niv
);
if
(
iv_copy
==
NULL
)
{
free
(
frame
);
return
NGHTTP2_ERR_NOMEM
;
}
}
else
{
iv_copy
=
NULL
;
}
if
((
flags
&
NGHTTP2_FLAG_ACK
)
==
0
)
{
...
...
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