BUG/MAJOR: stream-int: properly check the memory allocation return

In stream_int_register_handler(), we call si_alloc_appctx(si) but as a
mistake, instead of checking the return value for a NULL, we test <si>.
This bug was discovered under extreme memory contention (memory for only
two buffers with 500 connections waiting) and after 3 million failed
connections. While it was very hard to produce it, the fix is tagged
major because in theory it could happen when haproxy runs with a very
low "-m" setting preventing from allocating just the few bytes needed
for an appctx. But most users will never be able to trigger it. The
fix was confirmed to address the bug.

This fix must be backported to 1.5.
This commit is contained in:
Willy Tarreau 2014-12-22 19:34:00 +01:00
parent fe1ebcd2cf
commit a69fc9f803
1 changed files with 1 additions and 1 deletions

View File

@ -366,7 +366,7 @@ struct appctx *stream_int_register_handler(struct stream_interface *si, struct s
DPRINTF(stderr, "registering handler %p for si %p (was %p)\n", app, si, si->owner); DPRINTF(stderr, "registering handler %p for si %p (was %p)\n", app, si, si->owner);
appctx = si_alloc_appctx(si); appctx = si_alloc_appctx(si);
if (!si) if (!appctx)
return NULL; return NULL;
appctx_set_applet(appctx, app); appctx_set_applet(appctx, app);