Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asterisk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Voice
asterisk
Commits
2220be23
Commit
2220be23
authored
7 years ago
by
Kevin Harwell
Committed by
Gerrit Code Review
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge "AST-2018-006: Properly handle WebSocket frames with 0 length payload."
parents
bd549cf9
64361379
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
res/res_http_websocket.c
+13
-3
13 additions, 3 deletions
res/res_http_websocket.c
with
13 additions
and
3 deletions
res/res_http_websocket.c
+
13
−
3
View file @
2220be23
...
...
@@ -488,13 +488,20 @@ const char * AST_OPTIONAL_API_NAME(ast_websocket_session_id)(struct ast_websocke
* Note during the header parsing stage we try to read in small chunks just what we need, this
* is buffered data anyways, no expensive syscall required most of the time ...
*/
static
inline
int
ws_safe_read
(
struct
ast_websocket
*
session
,
char
*
buf
,
in
t
len
,
enum
ast_websocket_opcode
*
opcode
)
static
inline
int
ws_safe_read
(
struct
ast_websocket
*
session
,
char
*
buf
,
size_
t
len
,
enum
ast_websocket_opcode
*
opcode
)
{
ssize_t
rlen
;
int
xlen
=
len
;
char
*
rbuf
=
buf
;
int
sanity
=
10
;
ast_assert
(
len
>
0
);
if
(
!
len
)
{
errno
=
EINVAL
;
return
-
1
;
}
ao2_lock
(
session
);
if
(
!
session
->
stream
)
{
ao2_unlock
(
session
);
...
...
@@ -608,9 +615,12 @@ int AST_OPTIONAL_API_NAME(ast_websocket_read)(struct ast_websocket *session, cha
return
-
1
;
}
if
(
ws_safe_read
(
session
,
*
payload
,
*
payload_len
,
opcode
))
{
return
-
1
;
if
(
*
payload_len
)
{
if
(
ws_safe_read
(
session
,
*
payload
,
*
payload_len
,
opcode
))
{
return
-
1
;
}
}
/* If a mask is present unmask the payload */
if
(
mask_present
)
{
unsigned
int
pos
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment