From a936d07dbae4078ddbd599d79f653db08d00c874 Mon Sep 17 00:00:00 2001 From: nononame Date: Thu, 9 Jan 2014 20:49:30 +0100 Subject: [PATCH] bad index overflow protection of lws_lookup context->lws_lookup allocation size is (sizeof(struct libwebsocket *) * context->max_fds). The maximum index is (context->max_fds - 1). context->max_fds is not a valid index. --- lib/libwebsockets.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 6dc4d1d18..fc920bd8b 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -119,7 +119,7 @@ insert_wsi_socket_into_fds(struct libwebsocket_context *context, return 1; } - if (wsi->sock > context->max_fds) { + if (wsi->sock >= context->max_fds) { lwsl_err("Socket fd %d is too high (%d)\n", wsi->sock, context->max_fds); return 1;