delete_from_fd: assert if fd beyond the max_fds

Signed-off-by: songbuhuang <544824346@qq.com>
This commit is contained in:
songbuhuang 2022-09-17 16:58:46 +08:00 committed by Andy Green
parent 2c981f7670
commit 237506fed1
4 changed files with 9 additions and 4 deletions

View File

@ -119,7 +119,8 @@ struct lws;
int
insert_wsi(const struct lws_context *context, struct lws *wsi);
#define delete_from_fd(A,B) A->lws_lookup[B - lws_plat_socket_offset()] = 0
#define delete_from_fd(A,B) assert((int)A->max_fds > B - lws_plat_socket_offset()); \
A->lws_lookup[B - lws_plat_socket_offset()] = 0
#define LWS_PLAT_TIMER_TYPE TimerHandle_t
#define LWS_PLAT_TIMER_CB(name, var) void name(TimerHandle_t var)

View File

@ -46,5 +46,6 @@
lws_plat_socket_offset()] == 0); \
A->lws_lookup[B->desc.sockfd - \
lws_plat_socket_offset()] = B
#define delete_from_fd(A,B) A->lws_lookup[B - lws_plat_socket_offset()] = 0
#define delete_from_fd(A,B) assert((int)A->max_fds > B - lws_plat_socket_offset()); \
A->lws_lookup[B - lws_plat_socket_offset()] = 0

View File

@ -174,8 +174,10 @@ delete_from_fd(const struct lws_context *context, int fd)
struct lws **p, **done;
if (!context->max_fds_unrelated_to_ulimit) {
if (context->lws_lookup)
if (context->lws_lookup) {
assert((int)context->max_fds > fd - lws_plat_socket_offset());
context->lws_lookup[fd - lws_plat_socket_offset()] = NULL;
}
return;
}

View File

@ -116,7 +116,8 @@ struct lws;
int
insert_wsi(const struct lws_context *context, struct lws *wsi);
#define delete_from_fd(A,B) A->lws_lookup[B - lws_plat_socket_offset()] = 0
#define delete_from_fd(A,B) assert((int)A->max_fds > B - lws_plat_socket_offset()); \
A->lws_lookup[B - lws_plat_socket_offset()] = 0
#define LWS_PLAT_TIMER_TYPE TimerHandle_t
#define LWS_PLAT_TIMER_CB(name, var) void name(TimerHandle_t var)