]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cfgcond: always set the error string on openssl_version checks
authorWilly Tarreau <w@1wt.eu>
Fri, 3 Apr 2026 06:56:54 +0000 (08:56 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 3 Apr 2026 06:56:54 +0000 (08:56 +0200)
Using openssl_version_before() with an invalid argument results in "(null)"
appearing in the error message due to -1 being returned without the error
message being filled. Let's always fill the error message on error.

This was introduced in 2.5 with commit 3aeb3f9347 ("MINOR: cfgcond:
implements openssl_version_atleast and openssl_version_before"), and
this fix must be backported to 2.6.

src/cfgcond.c

index 07fe9c8fceaa64169ecbb86cf93e078f306d084d..9eebada3afccb4fb9076dc84123421fd88d676be 100644 (file)
@@ -272,8 +272,10 @@ int cfg_eval_cond_term(const struct cfg_cond_term *term, char **err)
                case CFG_PRED_OSSL_VERSION_ATLEAST: { // checks if the current openssl version is at least this one
                        int opensslret = openssl_compare_current_version(term->args[0].data.str.area);
 
-                       if (opensslret < -1) /* can't parse the string or no openssl available */
+                       if (opensslret < -1) { /* can't parse the string or no openssl available */
+                               memprintf(err, "invalid argument to conditional expression predicate '%s': '%s'", term->pred->word, term->args[0].data.str.area);
                                ret = -1;
+                       }
                        else
                                ret = opensslret <= 0;
                        break;
@@ -281,8 +283,10 @@ int cfg_eval_cond_term(const struct cfg_cond_term *term, char **err)
                case CFG_PRED_OSSL_VERSION_BEFORE: { // checks if the current openssl version is older than this one
                        int opensslret = openssl_compare_current_version(term->args[0].data.str.area);
 
-                       if (opensslret < -1) /* can't parse the string or no openssl available */
+                       if (opensslret < -1) { /* can't parse the string or no openssl available */
+                               memprintf(err, "invalid argument to conditional expression predicate '%s': '%s'", term->pred->word, term->args[0].data.str.area);
                                ret = -1;
+                       }
                        else
                                ret = opensslret > 0;
                        break;