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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Fork
libwebsockets
Commits
93f4fe55
Commit
93f4fe55
authored
6 years ago
by
Andy Green
Browse files
Options
Downloads
Patches
Plain Diff
lws_return_http_status: use /error.css if possible
parent
6104a25f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/roles/http/header.c
+11
-10
11 additions, 10 deletions
lib/roles/http/header.c
scripts/attack.sh
+2
-2
2 additions, 2 deletions
scripts/attack.sh
with
13 additions
and
12 deletions
lib/roles/http/header.c
+
11
−
10
View file @
93f4fe55
...
...
@@ -338,6 +338,7 @@ lws_return_http_status(struct lws *wsi, unsigned int code,
unsigned
char
*
p
=
pt
->
serv_buf
+
LWS_PRE
;
unsigned
char
*
start
=
p
;
unsigned
char
*
end
=
p
+
context
->
pt_serv_buf_size
-
LWS_PRE
;
char
*
body
=
(
char
*
)
start
+
context
->
pt_serv_buf_size
-
512
;
int
n
=
0
,
m
=
0
,
len
;
char
slen
[
20
];
...
...
@@ -372,9 +373,15 @@ lws_return_http_status(struct lws *wsi, unsigned int code,
&
p
,
end
))
return
1
;
len
=
35
+
(
int
)
strlen
(
html_body
)
+
sprintf
(
slen
,
"%d"
,
code
);
n
=
sprintf
(
slen
,
"%d"
,
len
);
len
=
lws_snprintf
(
body
,
510
,
"<html><head>"
"<meta charset=utf-8 http-equiv=
\"
Content-Language
\"
"
"content=
\"
en
\"
/>"
"<link rel=
\"
stylesheet
\"
type=
\"
text/css
\"
"
"href=
\"
/error.css
\"
/>"
"</head><body><h1>%u</h1>%s</body></html>"
,
code
,
html_body
);
n
=
sprintf
(
slen
,
"%d"
,
len
);
if
(
lws_add_http_header_by_token
(
wsi
,
WSI_TOKEN_HTTP_CONTENT_LENGTH
,
(
unsigned
char
*
)
slen
,
n
,
&
p
,
end
))
return
1
;
...
...
@@ -384,7 +391,6 @@ lws_return_http_status(struct lws *wsi, unsigned int code,
#if defined(LWS_WITH_HTTP2)
if
(
wsi
->
http2_substream
)
{
char
*
body
=
(
char
*
)
start
+
context
->
pt_serv_buf_size
-
512
;
/*
* for HTTP/2, the headers must be sent separately, since they
...
...
@@ -407,9 +413,6 @@ lws_return_http_status(struct lws *wsi, unsigned int code,
* ... but stash the body and send it as a priority next
* handle_POLLOUT
*/
len
=
sprintf
(
body
,
"<html><body><h1>%u</h1>%s</body></html>"
,
code
,
html_body
);
wsi
->
http
.
tx_content_length
=
len
;
wsi
->
http
.
tx_content_remain
=
len
;
...
...
@@ -429,11 +432,9 @@ lws_return_http_status(struct lws *wsi, unsigned int code,
* for http/1, we can just append the body after the finalized
* headers and send it all in one go.
*/
p
+=
lws_snprintf
((
char
*
)
p
,
end
-
p
-
1
,
"<html><body><h1>%u</h1>%s</body></html>"
,
code
,
html_body
);
n
=
lws_ptr_diff
(
p
,
start
);
n
=
lws_ptr_diff
(
p
,
start
)
+
len
;
memcpy
(
p
,
body
,
len
);
m
=
lws_write
(
wsi
,
start
,
n
,
LWS_WRITE_HTTP
);
if
(
m
!=
n
)
return
1
;
...
...
This diff is collapsed.
Click to expand it.
scripts/attack.sh
+
2
−
2
View file @
93f4fe55
...
...
@@ -45,12 +45,12 @@ function check {
fi
if
[
"
$1
"
=
"defaultplusforbidden"
]
;
then
cat
$CORPUS
>
/tmp/plusforb
echo
-e
-n
"HTTP/1.0 403 Forbidden
\x
0d
\x
0acontent-type: text/html
\x
0d
\x
0acontent-length: 3
8
\x
0d
\x
0a
\x
0d
\x
0a<html><body><h1>403</h1></body></html>"
>>
/tmp/plusforb
echo
-e
-n
"HTTP/1.0 403 Forbidden
\x
0d
\x
0acontent-type: text/html
\x
0d
\x
0acontent-length:
17
3
\x
0d
\x
0a
\x
0d
\x
0a<html><
head><meta charset=utf-8 http-equiv=
\"
Content-Language
\"
content=
\"
en
\"
/><link rel=
\"
stylesheet
\"
type=
\"
text/css
\"
href=
\"
/error.css
\"
/></head><
body><h1>403</h1></body></html>"
>>
/tmp/plusforb
diff /tmp/lwscap /tmp/plusforb
>
/dev/null
if
[
$?
-ne
0
]
;
then
cat
$CORPUS
>
/tmp/plusforb
echo
-e
-n
"HTTP/1.1 403 Forbidden
\x
0d
\x
0acontent-type: text/html
\x
0d
\x
0acontent-length: 3
8
\x
0d
\x
0a
\x
0d
\x
0a<html><body><h1>403</h1></body></html>"
>>
/tmp/plusforb
echo
-e
-n
"HTTP/1.1 403 Forbidden
\x
0d
\x
0acontent-type: text/html
\x
0d
\x
0acontent-length:
17
3
\x
0d
\x
0a
\x
0d
\x
0a<html><
head><meta charset=utf-8 http-equiv=
\"
Content-Language
\"
content=
\"
en
\"
/><link rel=
\"
stylesheet
\"
type=
\"
text/css
\"
href=
\"
/error.css
\"
/></head><
body><h1>403</h1></body></html>"
>>
/tmp/plusforb
diff /tmp/lwscap /tmp/plusforb
>
/dev/null
if
[
$?
-ne
0
]
;
then
...
...
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