Skip to main content
Homepage
Explore
Search or go to…
/
Sign in
Explore
Primary navigation
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
?
Collapse sidebar
Snippets
Groups
Projects
Show more breadcrumbs
Fork
libwebsockets
Commits
acbaee64
This project is archived. Its data is
read-only
.
Commit
acbaee64
authored
Jan 18, 2013
by
Andy Green
Browse files
Options
Downloads
Patches
Plain Diff
add lws_confirm_legit_wsi
Signed-off-by:
Andy Green
<
andy.green@linaro.org
>
parent
a1ce6be9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/libwebsockets.c
+32
-0
32 additions, 0 deletions
lib/libwebsockets.c
lib/output.c
+4
-0
4 additions, 0 deletions
lib/output.c
lib/private-libwebsockets.h
+3
-0
3 additions, 0 deletions
lib/private-libwebsockets.h
libwebsockets-api-doc.html
+17
-0
17 additions, 0 deletions
libwebsockets-api-doc.html
with
56 additions
and
0 deletions
lib/libwebsockets.c
+
32
−
0
View file @
acbaee64
...
@@ -2117,6 +2117,38 @@ libwebsocket_ensure_user_space(struct libwebsocket *wsi)
...
@@ -2117,6 +2117,38 @@ libwebsocket_ensure_user_space(struct libwebsocket *wsi)
return
wsi
->
user_space
;
return
wsi
->
user_space
;
}
}
/**
* lws_confirm_legit_wsi: returns nonzero if the wsi looks bad
*
* @wsi: struct libwebsocket to assess
*
* Performs consistecy checks on what the wsi claims and what the
* polling arrays hold. This'll catch a closed wsi still in use.
* Don't try to use on the listen (nonconnection) wsi as it will
* fail it. Otherwise 0 return == wsi seems consistent.
*/
int
lws_confirm_legit_wsi
(
struct
libwebsocket
*
wsi
)
{
struct
libwebsocket_context
*
context
;
if
(
!
(
wsi
&&
wsi
->
protocol
&&
wsi
->
protocol
->
owning_server
))
return
1
;
context
=
wsi
->
protocol
->
owning_server
;
if
(
!
context
)
return
2
;
if
(
!
wsi
->
position_in_fds_table
)
return
3
;
/* position in fds table looks bad */
if
(
context
->
fds
[
wsi
->
position_in_fds_table
].
fd
!=
wsi
->
sock
)
return
4
;
/* pollfd entry does not wait on our socket descriptor */
if
(
context
->
lws_lookup
[
wsi
->
sock
]
!=
wsi
)
return
5
;
/* lookup table does not agree with wsi */
return
0
;
}
static
void
lwsl_emit_stderr
(
const
char
*
line
)
static
void
lwsl_emit_stderr
(
const
char
*
line
)
{
{
...
...
...
...
This diff is collapsed.
Click to expand it.
lib/output.c
+
4
−
0
View file @
acbaee64
...
@@ -295,6 +295,10 @@ int libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf,
...
@@ -295,6 +295,10 @@ int libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf,
struct
lws_tokens
eff_buf
;
struct
lws_tokens
eff_buf
;
int
m
;
int
m
;
if
(
lws_confirm_legit_wsi
(
wsi
))
{
lwsl_err
(
"libwebsocket_write on illegitimate wsi
\n
"
);
return
-
1
;
}
if
(
len
==
0
&&
protocol
!=
LWS_WRITE_CLOSE
)
{
if
(
len
==
0
&&
protocol
!=
LWS_WRITE_CLOSE
)
{
lwsl_warn
(
"zero length libwebsocket_write attempt
\n
"
);
lwsl_warn
(
"zero length libwebsocket_write attempt
\n
"
);
return
0
;
return
0
;
...
...
...
...
This diff is collapsed.
Click to expand it.
lib/private-libwebsockets.h
+
3
−
0
View file @
acbaee64
...
@@ -491,6 +491,9 @@ lws_issue_raw_ext_access(struct libwebsocket *wsi,
...
@@ -491,6 +491,9 @@ lws_issue_raw_ext_access(struct libwebsocket *wsi,
extern
int
extern
int
_libwebsocket_rx_flow_control
(
struct
libwebsocket
*
wsi
);
_libwebsocket_rx_flow_control
(
struct
libwebsocket
*
wsi
);
extern
int
lws_confirm_legit_wsi
(
struct
libwebsocket
*
wsi
);
extern
int
extern
int
user_callback_handle_rxflow
(
callback_function
,
struct
libwebsocket_context
*
context
,
user_callback_handle_rxflow
(
callback_function
,
struct
libwebsocket_context
*
context
,
struct
libwebsocket
*
wsi
,
struct
libwebsocket
*
wsi
,
...
...
...
...
This diff is collapsed.
Click to expand it.
libwebsockets-api-doc.html
+
17
−
0
View file @
acbaee64
...
@@ -350,6 +350,23 @@ having to take any care about data visibility between the processes, it'll
...
@@ -350,6 +350,23 @@ having to take any care about data visibility between the processes, it'll
"just work".
"just work".
</blockquote>
</blockquote>
<hr>
<hr>
<h2>
lws_confirm_legit_wsi -
</h2>
<i>
int
</i>
<b>
lws_confirm_legit_wsi
</b>
(
<i>
struct libwebsocket *
</i>
<b>
wsi
</b>
)
<h3>
Arguments
</h3>
<dl>
<dt><b>
wsi
</b>
<dd>
struct libwebsocket to assess
</dl>
<h3>
Description
</h3>
<blockquote>
Performs consistecy checks on what the wsi claims and what the
polling arrays hold. This'll catch a closed wsi still in use.
Don't try to use on the listen (nonconnection) wsi as it will
fail it. Otherwise 0 return == wsi seems consistent.
</blockquote>
<hr>
<h2>
lws_set_log_level - Set the logging bitfield
</h2>
<h2>
lws_set_log_level - Set the logging bitfield
</h2>
<i>
void
</i>
<i>
void
</i>
<b>
lws_set_log_level
</b>
<b>
lws_set_log_level
</b>
...
...
...
...
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