Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libnice
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
cpp-libs
libnice
Commits
cd6f572e
Commit
cd6f572e
authored
Mar 27, 2014
by
Olivier Crête
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
turn-tcp: Don't corrupt messages
parent
1a327d33
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
21 deletions
+13
-21
socket/tcp-turn.c
socket/tcp-turn.c
+13
-21
No files found.
socket/tcp-turn.c
View file @
cd6f572e
...
@@ -234,6 +234,7 @@ socket_send_message (NiceSocket *sock, const NiceAddress *to,
...
@@ -234,6 +234,7 @@ socket_send_message (NiceSocket *sock, const NiceAddress *to,
gint
ret
;
gint
ret
;
guint
n_bufs
;
guint
n_bufs
;
guint16
header_buf
;
guint16
header_buf
;
guint
offset
=
0
;
/* Count the number of buffers. */
/* Count the number of buffers. */
if
(
message
->
n_buffers
==
-
1
)
{
if
(
message
->
n_buffers
==
-
1
)
{
...
@@ -247,30 +248,15 @@ socket_send_message (NiceSocket *sock, const NiceAddress *to,
...
@@ -247,30 +248,15 @@ socket_send_message (NiceSocket *sock, const NiceAddress *to,
/* Allocate a new array of buffers, covering all the buffers in the input
/* Allocate a new array of buffers, covering all the buffers in the input
* @message, but with an additional one for a header and one for a footer. */
* @message, but with an additional one for a header and one for a footer. */
local_bufs
=
g_malloc_n
(
n_bufs
+
2
,
sizeof
(
GOutputVector
));
local_bufs
=
g_malloc_n
(
n_bufs
+
1
,
sizeof
(
GOutputVector
));
local_message
.
buffers
=
local_bufs
;
local_message
.
buffers
=
local_bufs
;
local_message
.
n_buffers
=
n_bufs
+
2
;
local_message
.
n_buffers
=
n_bufs
+
1
;
/* Copy the existing buffers across. */
for
(
j
=
0
;
j
<
n_bufs
;
j
++
)
{
local_bufs
[
j
+
1
].
buffer
=
message
->
buffers
[
j
].
buffer
;
local_bufs
[
j
+
1
].
size
=
message
->
buffers
[
j
].
size
;
}
/* Header buffer. */
if
(
priv
->
compatibility
==
NICE_TURN_SOCKET_COMPATIBILITY_GOOGLE
)
{
if
(
priv
->
compatibility
==
NICE_TURN_SOCKET_COMPATIBILITY_GOOGLE
)
{
header_buf
=
htons
(
output_message_get_size
(
message
));
local_bufs
[
0
].
buffer
=
&
header_buf
;
local_bufs
[
0
].
buffer
=
&
header_buf
;
local_bufs
[
0
].
size
=
sizeof
(
header_buf
);
local_bufs
[
0
].
size
=
sizeof
(
header_buf
);
}
else
{
offset
=
1
;
/* Skip over the allocated header buffer. */
}
else
if
(
priv
->
compatibility
==
NICE_TURN_SOCKET_COMPATIBILITY_DRAFT9
||
local_message
.
buffers
++
;
local_message
.
n_buffers
--
;
}
/* Tail buffer. */
if
(
priv
->
compatibility
==
NICE_TURN_SOCKET_COMPATIBILITY_DRAFT9
||
priv
->
compatibility
==
NICE_TURN_SOCKET_COMPATIBILITY_RFC5766
)
{
priv
->
compatibility
==
NICE_TURN_SOCKET_COMPATIBILITY_RFC5766
)
{
gsize
message_len
=
output_message_get_size
(
message
);
gsize
message_len
=
output_message_get_size
(
message
);
gsize
padlen
=
(
message_len
%
4
)
?
4
-
(
message_len
%
4
)
:
0
;
gsize
padlen
=
(
message_len
%
4
)
?
4
-
(
message_len
%
4
)
:
0
;
...
@@ -278,10 +264,16 @@ socket_send_message (NiceSocket *sock, const NiceAddress *to,
...
@@ -278,10 +264,16 @@ socket_send_message (NiceSocket *sock, const NiceAddress *to,
local_bufs
[
n_bufs
].
buffer
=
&
padbuf
;
local_bufs
[
n_bufs
].
buffer
=
&
padbuf
;
local_bufs
[
n_bufs
].
size
=
padlen
;
local_bufs
[
n_bufs
].
size
=
padlen
;
}
else
{
}
else
{
/* Skip over the allocated tail buffer. */
local_message
.
n_buffers
=
n_bufs
;
local_message
.
n_buffers
--
;
}
}
/* Copy the existing buffers across. */
for
(
j
=
0
;
j
<
n_bufs
;
j
++
)
{
local_bufs
[
j
+
offset
].
buffer
=
message
->
buffers
[
j
].
buffer
;
local_bufs
[
j
+
offset
].
size
=
message
->
buffers
[
j
].
size
;
}
ret
=
nice_socket_send_messages
(
priv
->
base_socket
,
to
,
&
local_message
,
1
);
ret
=
nice_socket_send_messages
(
priv
->
base_socket
,
to
,
&
local_message
,
1
);
g_free
(
local_bufs
);
g_free
(
local_bufs
);
...
...
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