Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libwebsockets
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is archived. Its data is
read-only
.
Show more breadcrumbs
Fork
libwebsockets
Commits
40f4bc9c
Commit
40f4bc9c
authored
Jan 20, 2016
by
Andy Green
Browse files
Options
Downloads
Patches
Plain Diff
parser issue_char audit
Signed-off-by:
Andy Green
<
andy.green@linaro.org
>
parent
edd3a2d6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/parsers.c
+19
-10
19 additions, 10 deletions
lib/parsers.c
with
19 additions
and
10 deletions
lib/parsers.c
+
19
−
10
View file @
40f4bc9c
...
...
@@ -189,12 +189,23 @@ static int issue_char(struct libwebsocket *wsi, unsigned char c)
wsi
->
u
.
hdr
.
current_token_limit
)
{
lwsl_warn
(
"header %i exceeds limit
\n
"
,
wsi
->
u
.
hdr
.
parser_state
);
return
1
;
}
;
}
wsi
->
u
.
hdr
.
ah
->
data
[
wsi
->
u
.
hdr
.
ah
->
pos
++
]
=
c
;
if
(
c
)
wsi
->
u
.
hdr
.
ah
->
frags
[
wsi
->
u
.
hdr
.
ah
->
next_frag_index
].
len
++
;
/* Insert a null character when we *hit* the limit: */
if
(
wsi
->
u
.
hdr
.
ah
->
frags
[
wsi
->
u
.
hdr
.
ah
->
next_frag_index
].
len
==
wsi
->
u
.
hdr
.
current_token_limit
)
{
if
(
wsi
->
u
.
hdr
.
ah
->
pos
==
sizeof
(
wsi
->
u
.
hdr
.
ah
->
data
))
{
lwsl_warn
(
"excessive header content 2
\n
"
);
return
-
1
;
}
wsi
->
u
.
hdr
.
ah
->
data
[
wsi
->
u
.
hdr
.
ah
->
pos
++
]
=
'\0'
;
lwsl_warn
(
"header %i exceeds limit %d
\n
"
,
wsi
->
u
.
hdr
.
parser_state
,
wsi
->
u
.
hdr
.
current_token_limit
);
}
return
0
;
}
...
...
@@ -294,6 +305,8 @@ int libwebsocket_parse(
switch
(
wsi
->
u
.
hdr
.
ups
)
{
case
URIPS_IDLE
:
if
(
!
c
)
return
-
1
;
/* issue the first / always */
if
(
c
==
'/'
)
wsi
->
u
.
hdr
.
ups
=
URIPS_SEEN_SLASH
;
...
...
@@ -356,7 +369,8 @@ int libwebsocket_parse(
if
(
c
==
'?'
)
{
/* start of URI arguments */
/* seal off uri header */
wsi
->
u
.
hdr
.
ah
->
data
[
wsi
->
u
.
hdr
.
ah
->
pos
++
]
=
'\0'
;
if
(
issue_char
(
wsi
,
'\0'
)
<
0
)
return
-
1
;
/* move to using WSI_TOKEN_HTTP_URI_ARGS */
wsi
->
u
.
hdr
.
ah
->
next_frag_index
++
;
...
...
@@ -504,13 +518,8 @@ start_fragment:
wsi
->
u
.
hdr
.
ah
->
frags
[
n
].
next_frag_index
=
wsi
->
u
.
hdr
.
ah
->
next_frag_index
;
if
(
wsi
->
u
.
hdr
.
ah
->
pos
==
sizeof
(
wsi
->
u
.
hdr
.
ah
->
data
))
{
lwsl_warn
(
"excessive header content
\n
"
);
if
(
issue_char
(
wsi
,
' '
)
<
0
)
return
-
1
;
}
wsi
->
u
.
hdr
.
ah
->
data
[
wsi
->
u
.
hdr
.
ah
->
pos
++
]
=
' '
;
wsi
->
u
.
hdr
.
ah
->
frags
[
wsi
->
u
.
hdr
.
ah
->
next_frag_index
].
len
++
;
break
;
/* skipping arg part of a name we didn't recognize */
...
...
@@ -820,7 +829,7 @@ handle_first:
return
1
;
}
if
(
wsi
->
u
.
ws
.
rx_u
buf
_head
+
LWS_
PRE
>=
wsi
->
u
.
ws
.
rx_ubuf_alloc
)
{
if
(
wsi
->
u
.
ws
.
rx_u
ser_buffer
_head
+
LWS_
SEND_BUFFER_PRE_PADDING
>=
wsi
->
u
.
ws
.
rx_ubuf_alloc
)
{
lwsl_err
(
"Attempted overflow
\n
"
);
return
-
1
;
}
...
...
...
...
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
sign in
to comment