]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: proxy: fix email-alert leak on deinit() (2nd try)
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 17 Jun 2024 16:53:48 +0000 (18:53 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Mon, 17 Jun 2024 17:37:29 +0000 (19:37 +0200)
commit9d312212dfa3eaf678c5fabcc6f1045192b8ef19
treeb55a5eeae87d1e879057ec84d367980d627e8480
parentee8be55942fd82813863bae7795d60289821fb38
BUG/MINOR: proxy: fix email-alert leak on deinit() (2nd try)

As shown in GH #2608 and ("BUG/MEDIUM: proxy: fix email-alert invalid
free"), simply calling free_email_alert() from free_proxy() is not the
right thing to do.

In this patch, we reuse proxy->email_alert.set memory space to introduce
proxy->email_alert.flags in order to support 2 flags:
PR_EMAIL_ALERT_SET (to mimic proxy->email_alert.set) and
PR_EMAIL_ALERT_RESOLVED (set once init_email_alert() was called on the
proxy to resolve email_alert.mailer pointer).

Thanks to PR_EMAIL_ALERT_RESOLVED flag, free_email_alert() may now
properly handle the freeing of proxy email_alert settings: if the RESOLVED
flag is set, then it means the .email_alert.mailers.name parsing hint was
replaced by the actual mailers pointer, thus no free should be attempted.

No backport needed: as described in ("BUG/MEDIUM: proxy: fix email-alert
invalid free"), this historical leak is not sensitive as it cannot be
triggered during runtime.. thus given that the fix is not backport-
friendly, it's not worth the trouble.
include/haproxy/mailers-t.h
include/haproxy/proxy-t.h
src/cfgparse-listen.c
src/cfgparse.c
src/mailers.c
src/proxy.c