[Libwebsockets] Integer truncation in automatic setting of max_http_header_pool

Silas Parker skyhisi+libwebsockets at gmail.com
Tue Jun 19 11:36:02 CEST 2018


Thanks Andy, that's great.
On Tue, 19 Jun 2018 at 10:17, Andy Green <andy at warmcat.com> wrote:
>
>
>
> On 06/19/2018 05:12 PM, Silas Parker wrote:
> > Hi Andy,
> >
> > Just tracked down an issue that was preventing a custom libwebsockets
> > based server from working under Docker.
> >
> > If max_http_header_pool (short int) is zero in the context creation
> > info, it takes the value from max_fds (int), and max_fds under Docker
> > was being set to 1048576 (0x100000), rather than 1024 like normal, so
> > it was being converted to 0 when assigned to max_http_header_pool.
> >
> > I think the fix would be to either increase the width of
> > max_http_header_pool to an int, or to saturate the assignment. The
> > following diff is the saturation fix (assuming a short is 2 bytes):
> >
> > diff --git a/lib/core/context.c b/lib/core/context.c
> > index 07f931c3..ebcd16af 100644
> > --- a/lib/core/context.c
> > +++ b/lib/core/context.c
> > @@ -1377,7 +1377,7 @@ lws_create_context(const struct
> > lws_context_creation_info *info)
> >                          context->max_http_header_pool =
> >                                          info->max_http_header_pool2;
> >                  else
> > -                       context->max_http_header_pool = context->max_fds;
> > +                       context->max_http_header_pool =
> > context->max_fds > 32767 ? 32767 : context->max_fds;
> >
> >          if (info->fd_limit_per_thread)
> >                  context->fd_limit_per_thread = info->fd_limit_per_thread;
>
> There's already a fix in master
>
> https://libwebsockets.org/git/libwebsockets/commit/?id=80d2abc1fbe2e654ad90eb9cfd333d4f949e5443
>
> and v3.0-stable
>
> https://libwebsockets.org/git/libwebsockets/commit/?h=v3.0-stable&id=bdedd1a910106af02dc7c24b5a91faa013b6c763
>
> since a few hours ago, after a dude on github found the same thing last
> night (but wrt running lws under IDE debugging, which causes huge uname -r)
>
> -Andy
>
> > Thanks,
> > Silas
> > _______________________________________________
> > Libwebsockets mailing list
> > Libwebsockets at ml.libwebsockets.org
> > https://libwebsockets.org/mailman/listinfo/libwebsockets
> >



More information about the Libwebsockets mailing list