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
7a39f60f
Commit
7a39f60f
authored
May 16, 2014
by
Olivier Crête
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stunmessage: Accept NULL terminated buffers for fast speed validation
parent
747364e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
stun/stunmessage.c
stun/stunmessage.c
+4
-3
stun/stunmessage.h
stun/stunmessage.h
+3
-2
No files found.
stun/stunmessage.c
View file @
7a39f60f
...
@@ -538,11 +538,11 @@ stun_message_append_error (StunMessage *msg, StunError code)
...
@@ -538,11 +538,11 @@ stun_message_append_error (StunMessage *msg, StunError code)
* they’re STUN packets. If they look like they might be, their buffers are
* they’re STUN packets. If they look like they might be, their buffers are
* compacted to allow a more thorough check. */
* compacted to allow a more thorough check. */
ssize_t
stun_message_validate_buffer_length_fast
(
StunInputVector
*
buffers
,
ssize_t
stun_message_validate_buffer_length_fast
(
StunInputVector
*
buffers
,
unsigned
int
n_buffers
,
size_t
total_length
,
bool
has_padding
)
int
n_buffers
,
size_t
total_length
,
bool
has_padding
)
{
{
size_t
mlen
;
size_t
mlen
;
if
(
total_length
<
1
||
n_buffers
<
1
)
if
(
total_length
<
1
||
n_buffers
==
0
||
buffers
[
0
].
buffer
==
NULL
)
{
{
stun_debug
(
"STUN error: No data!
\n
"
);
stun_debug
(
"STUN error: No data!
\n
"
);
return
STUN_MESSAGE_BUFFER_INVALID
;
return
STUN_MESSAGE_BUFFER_INVALID
;
...
@@ -569,7 +569,8 @@ ssize_t stun_message_validate_buffer_length_fast (StunInputVector *buffers,
...
@@ -569,7 +569,8 @@ ssize_t stun_message_validate_buffer_length_fast (StunInputVector *buffers,
unsigned
int
i
;
unsigned
int
i
;
/* Skip bytes. */
/* Skip bytes. */
for
(
i
=
0
;
i
<
n_buffers
;
i
++
)
{
for
(
i
=
0
;
(
n_buffers
>=
0
&&
i
<
(
unsigned
int
)
n_buffers
)
||
(
n_buffers
<
0
&&
buffers
[
i
].
buffer
!=
NULL
);
i
++
)
{
if
(
buffers
[
i
].
size
<=
skip_remaining
)
if
(
buffers
[
i
].
size
<=
skip_remaining
)
skip_remaining
-=
buffers
[
i
].
size
;
skip_remaining
-=
buffers
[
i
].
size
;
else
else
...
...
stun/stunmessage.h
View file @
7a39f60f
...
@@ -904,7 +904,8 @@ typedef struct {
...
@@ -904,7 +904,8 @@ typedef struct {
* stun_message_validate_buffer_length_fast:
* stun_message_validate_buffer_length_fast:
* @buffers: (array length=n_buffers) (in caller-allocated): array of contiguous
* @buffers: (array length=n_buffers) (in caller-allocated): array of contiguous
* #StunInputVectors containing already-received message data
* #StunInputVectors containing already-received message data
* @n_buffers: number of entries in @buffers
* @n_buffers: number of entries in @buffers or if -1 , then buffers is
* terminated by a #StunInputVector with the buffer pointer being %NULL.
* @total_length: total number of valid bytes stored consecutively in @buffers
* @total_length: total number of valid bytes stored consecutively in @buffers
* @has_padding: %TRUE if attributes should be padded to 4-byte boundaries
* @has_padding: %TRUE if attributes should be padded to 4-byte boundaries
*
*
...
@@ -926,7 +927,7 @@ typedef struct {
...
@@ -926,7 +927,7 @@ typedef struct {
* Since: 0.1.5
* Since: 0.1.5
*/
*/
ssize_t
stun_message_validate_buffer_length_fast
(
StunInputVector
*
buffers
,
ssize_t
stun_message_validate_buffer_length_fast
(
StunInputVector
*
buffers
,
unsigned
int
n_buffers
,
size_t
total_length
,
bool
has_padding
);
int
n_buffers
,
size_t
total_length
,
bool
has_padding
);
/**
/**
* stun_message_id:
* stun_message_id:
...
...
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