Function flt_ot_var_set() did not check whether the variable was
successfully set or not.  In case of failure, the value -1 is returned.

--
Miroslav Zagorac
Senior Developer
>From 731892071c47540e2ed04d539121546194322731 Mon Sep 17 00:00:00 2001
From: Miroslav Zagorac <mzago...@haproxy.com>
Date: Tue, 1 Mar 2022 18:42:54 +0100
Subject: [PATCH 06/16] BUG/MINOR: opentracing: setting the return value in
 function flt_ot_var_set()

Function flt_ot_var_set() did not check whether the variable was
successfully set or not.  In case of failure, the value -1 is returned.
---
 addons/ot/src/vars.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/addons/ot/src/vars.c b/addons/ot/src/vars.c
index fa2a0bd06..dd40e2138 100644
--- a/addons/ot/src/vars.c
+++ b/addons/ot/src/vars.c
@@ -332,7 +332,13 @@ int flt_ot_var_set(struct stream *s, const char *scope, const char *prefix, cons
 
 	flt_ot_smp_init(s, &smp, opt, SMP_T_STR, value);
 
-	vars_set_by_name_ifexist(var_name, retval, &smp);
+	if (vars_set_by_name_ifexist(var_name, retval, &smp) == 0) {
+		FLT_OT_ERR("failed to set variable '%s'", var_name);
+
+		retval = -1;
+	} else {
+		FLT_OT_DBG(2, "variable '%s' set", var_name);
+	}
 
 	FLT_OT_RETURN(retval);
 }
-- 
2.30.2

Reply via email to