diff --git a/lib/context.c b/lib/context.c index 47976fbb..6125ee48 100644 --- a/lib/context.c +++ b/lib/context.c @@ -643,7 +643,11 @@ lws_create_context(struct lws_context_creation_info *info) if (info->max_http_header_data) context->max_http_header_data = info->max_http_header_data; else - context->max_http_header_data = LWS_DEF_HEADER_LEN; + if (info->max_http_header_data2) + context->max_http_header_data = + info->max_http_header_data2; + else + context->max_http_header_data = LWS_DEF_HEADER_LEN; if (info->max_http_header_pool) context->max_http_header_pool = info->max_http_header_pool; else diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index f71ab79a..341d4b18 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -1501,6 +1501,10 @@ struct lws_http_mount { * defines the max chunk of file that can be sent at once. * At the risk of lws having to buffer failed large sends, it * can be increased to, eg, 128KiB to improve throughput. + * @max_http_header_data2 CONTEXT: if @max_http_header_data is 0 and this + * is nonzero, this will be used in place of the default. It's + * like this for compatibility with the original short version, + * this is unsigned int length. */ struct lws_context_creation_info { @@ -1544,6 +1548,7 @@ struct lws_context_creation_info { const struct lws_http_mount *mounts; /* VH */ const char *server_string; /* context */ unsigned int pt_serv_buf_size; /* context */ + unsigned int max_http_header_data2; /* context */ /* Add new things just above here ---^ * This is part of the ABI, don't needlessly break compatibility diff --git a/lib/parsers.c b/lib/parsers.c index 0dea47f1..dead8e9f 100644 --- a/lib/parsers.c +++ b/lib/parsers.c @@ -460,7 +460,7 @@ char *lws_hdr_simple_ptr(struct lws *wsi, enum lws_token_indexes h) int LWS_WARN_UNUSED_RESULT lws_pos_in_bounds(struct lws *wsi) { - if (wsi->u.hdr.ah->pos < wsi->context->max_http_header_data) + if (wsi->u.hdr.ah->pos < (unsigned int)wsi->context->max_http_header_data) return 0; if (wsi->u.hdr.ah->pos == wsi->context->max_http_header_data) { diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h index 8450c43c..c8990c08 100644 --- a/lib/private-libwebsockets.h +++ b/lib/private-libwebsockets.h @@ -520,7 +520,7 @@ struct lws_fd_hashtable { */ struct lws_fragments { - unsigned short offset; + unsigned int offset; unsigned short len; unsigned char nfrag; /* which ah->frag[] continues this content, or 0 */ }; @@ -548,12 +548,12 @@ struct allocated_headers { unsigned char rx[2048]; unsigned int rxpos; unsigned int rxlen; + unsigned int pos; #ifndef LWS_NO_CLIENT char initial_handshake_hash_base64[30]; #endif - unsigned short pos; unsigned char in_use; unsigned char nfrag; }; @@ -742,6 +742,7 @@ struct lws_context { unsigned int fd_limit_per_thread; unsigned int timeout_secs; unsigned int pt_serv_buf_size; + int max_http_header_data; /* * set to the Thread ID that's doing the service loop just before entry @@ -752,7 +753,6 @@ struct lws_context { volatile int service_tid; int service_tid_detected; - short max_http_header_data; short max_http_header_pool; short count_threads; short plugin_protocol_count; @@ -906,7 +906,7 @@ struct _lws_header_related { enum uri_path_states ups; enum uri_esc_states ues; short lextable_pos; - unsigned short current_token_limit; + unsigned int current_token_limit; #ifndef LWS_NO_CLIENT unsigned short c_port; #endif