mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 13:51:26 +02:00
MINOR: sample: improve error reporting on missing arg to strcmp() converter
Calling the strcmp() converter with no argument yields this strange error: [ALERT] (31439) : parsing [test.cfg:3] : error detected in frontend 'f' while parsing 'http-request redirect' rule : failed to parse sample expression <src,strcmp]> : invalid args in converter 'strcmp' : failed to register variable name ''. This is because the vars name check tries to see if it can create such a variable having an empty name. Let's at least make a special case of the missing argument. Now we can read a more explicit: [ALERT] (31655) : parsing [test.cfg:3] : error detected in frontend 'f' while parsing 'http-request redirect' rule : failed to parse sample expression <src,strcmp]> : invalid args in converter 'strcmp' : missing variable name. This was done for secure_strcmp() as well.
This commit is contained in:
parent
02bd68431b
commit
a1169b6231
10
src/sample.c
10
src/sample.c
@ -3591,6 +3591,11 @@ static int sample_conv_mqtt_is_valid(const struct arg *arg_p, struct sample *smp
|
|||||||
static int smp_check_strcmp(struct arg *args, struct sample_conv *conv,
|
static int smp_check_strcmp(struct arg *args, struct sample_conv *conv,
|
||||||
const char *file, int line, char **err)
|
const char *file, int line, char **err)
|
||||||
{
|
{
|
||||||
|
if (!args[0].data.str.data) {
|
||||||
|
memprintf(err, "missing variable name");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Try to decode a variable. */
|
/* Try to decode a variable. */
|
||||||
if (vars_check_arg(&args[0], NULL))
|
if (vars_check_arg(&args[0], NULL))
|
||||||
return 1;
|
return 1;
|
||||||
@ -3607,6 +3612,11 @@ static int smp_check_strcmp(struct arg *args, struct sample_conv *conv,
|
|||||||
static int smp_check_secure_memcmp(struct arg *args, struct sample_conv *conv,
|
static int smp_check_secure_memcmp(struct arg *args, struct sample_conv *conv,
|
||||||
const char *file, int line, char **err)
|
const char *file, int line, char **err)
|
||||||
{
|
{
|
||||||
|
if (!args[0].data.str.data) {
|
||||||
|
memprintf(err, "missing variable name");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Try to decode a variable. */
|
/* Try to decode a variable. */
|
||||||
if (vars_check_arg(&args[0], NULL))
|
if (vars_check_arg(&args[0], NULL))
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user