Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Matt Johnston
dropbear
Commits
0e0ff515
Commit
0e0ff515
authored
May 20, 2014
by
Ronny Meeus
Browse files
Limit size of the iovect passed to writev in packet.c
parent
cd700aaf
Changes
1
Hide whitespace changes
Inline
Side-by-side
packet.c
View file @
0e0ff515
...
...
@@ -64,13 +64,24 @@ void write_packet() {
struct
iovec
*
iov
=
NULL
;
int
i
;
struct
Link
*
l
;
int
iov_max_count
;
#endif
TRACE2
((
"enter write_packet"
))
dropbear_assert
(
!
isempty
(
&
ses
.
writequeue
));
#ifdef HAVE_WRITEV
iov
=
m_malloc
(
sizeof
(
*
iov
)
*
ses
.
writequeue
.
count
);
#ifndef IOV_MAX
#define IOV_MAX UIO_MAXIOV
#endif
/* Make sure the size of the iov is below the maximum allowed by the OS. */
iov_max_count
=
ses
.
writequeue
.
count
;
if
(
iov_max_count
>
IOV_MAX
)
iov_max_count
=
IOV_MAX
;
iov
=
m_malloc
(
sizeof
(
*
iov
)
*
iov_max_count
);
for
(
l
=
ses
.
writequeue
.
head
,
i
=
0
;
l
;
l
=
l
->
link
,
i
++
)
{
writebuf
=
(
buffer
*
)
l
->
item
;
...
...
@@ -83,7 +94,7 @@ void write_packet() {
iov
[
i
].
iov_base
=
buf_getptr
(
writebuf
,
len
);
iov
[
i
].
iov_len
=
len
;
}
written
=
writev
(
ses
.
sock_out
,
iov
,
ses
.
writequeue
.
count
);
written
=
writev
(
ses
.
sock_out
,
iov
,
iov_max_
count
);
if
(
written
<
0
)
{
if
(
errno
==
EINTR
)
{
m_free
(
iov
);
...
...
Write
Preview
Supports
Markdown
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