From: Christopher Faulet Date: Wed, 2 Jun 2021 09:48:42 +0000 (+0200) Subject: BUG/MINOR: vars: Be sure to have a session to get checks variables X-Git-Tag: v2.5-dev1~211 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c4439f71b0515c143c5bfc8aa5102b2be7cba7b6;p=thirdparty%2Fhaproxy.git BUG/MINOR: vars: Be sure to have a session to get checks variables It is now possible to get any variables from the cli. Concretely, only variables in the PROC scope can be retrieved because there is neither stream nor session defined. But, nothing forbids anyone to try to get a variable in any scope. No value will be found, but it is allowed. Thus, we must be sure to not rely on an undefined session or stream in that case. Especially, the session must be tested before retrieving variables in CHECK scope. This patch should fix the issue #1249. It must be backported to 2.4. --- diff --git a/src/vars.c b/src/vars.c index 15dcb3c3d1..5b35aa391b 100644 --- a/src/vars.c +++ b/src/vars.c @@ -55,7 +55,7 @@ static inline struct vars *get_vars(struct session *sess, struct stream *strm, e case SCOPE_SESS: return sess ? &sess->vars : NULL; case SCOPE_CHECK: { - struct check *check = objt_check(sess->origin); + struct check *check = sess ? objt_check(sess->origin) : NULL; return check ? &check->vars : NULL; }