MINOR: http-fetch: Don't check if argument list is set in sample fetches

The list is always defined by definition. Thus there is no reason to test
it. There is also plenty of checks on arguments types while it is already
validated during the configuration parsing. But one thing at a time.

This patch should fix the issue #1087.
This commit is contained in:
Christopher Faulet 2021-01-29 11:22:15 +01:00
parent bdbd5db2a5
commit 623af93722
1 changed files with 23 additions and 28 deletions

View File

@ -769,15 +769,13 @@ static int smp_fetch_fhdr(const struct arg *args, struct sample *smp, const char
smp->ctx.a[0] = ctx; smp->ctx.a[0] = ctx;
} }
if (args) { if (args[0].type != ARGT_STR)
if (args[0].type != ARGT_STR) return 0;
return 0; name.ptr = args[0].data.str.area;
name.ptr = args[0].data.str.area; name.len = args[0].data.str.data;
name.len = args[0].data.str.data;
if (args[1].type == ARGT_SINT) if (args[1].type == ARGT_SINT)
occ = args[1].data.sint; occ = args[1].data.sint;
}
if (!htx) if (!htx)
return 0; return 0;
@ -819,7 +817,7 @@ static int smp_fetch_fhdr_cnt(const struct arg *args, struct sample *smp, const
if (!htx) if (!htx)
return 0; return 0;
if (args && args->type == ARGT_STR) { if (args->type == ARGT_STR) {
name.ptr = args->data.str.area; name.ptr = args->data.str.area;
name.len = args->data.str.data; name.len = args->data.str.data;
} else { } else {
@ -851,7 +849,7 @@ static int smp_fetch_hdr_names(const struct arg *args, struct sample *smp, const
if (!htx) if (!htx)
return 0; return 0;
if (args && args->type == ARGT_STR) if (args->type == ARGT_STR)
del = *args[0].data.str.area; del = *args[0].data.str.area;
temp = get_trash_chunk(); temp = get_trash_chunk();
@ -900,15 +898,13 @@ static int smp_fetch_hdr(const struct arg *args, struct sample *smp, const char
smp->ctx.a[0] = ctx; smp->ctx.a[0] = ctx;
} }
if (args) { if (args[0].type != ARGT_STR)
if (args[0].type != ARGT_STR) return 0;
return 0; name.ptr = args[0].data.str.area;
name.ptr = args[0].data.str.area; name.len = args[0].data.str.data;
name.len = args[0].data.str.data;
if (args[1].type == ARGT_SINT) if (args[1].type == ARGT_SINT)
occ = args[1].data.sint; occ = args[1].data.sint;
}
if (!htx) if (!htx)
return 0; return 0;
@ -960,7 +956,7 @@ static int smp_fetch_hdr_cnt(const struct arg *args, struct sample *smp, const c
if (!htx) if (!htx)
return 0; return 0;
if (args && args->type == ARGT_STR) { if (args->type == ARGT_STR) {
name.ptr = args->data.str.area; name.ptr = args->data.str.area;
name.len = args->data.str.data; name.len = args->data.str.data;
} else { } else {
@ -1341,7 +1337,7 @@ static int smp_fetch_http_auth(const struct arg *args, struct sample *smp, const
struct channel *chn = SMP_REQ_CHN(smp); struct channel *chn = SMP_REQ_CHN(smp);
struct htx *htx = smp_prefetch_htx(smp, chn, NULL, 1); struct htx *htx = smp_prefetch_htx(smp, chn, NULL, 1);
if (!args || args->type != ARGT_USR) if (args->type != ARGT_USR)
return 0; return 0;
if (!htx) if (!htx)
@ -1361,7 +1357,7 @@ static int smp_fetch_http_auth_grp(const struct arg *args, struct sample *smp, c
struct channel *chn = SMP_REQ_CHN(smp); struct channel *chn = SMP_REQ_CHN(smp);
struct htx *htx = smp_prefetch_htx(smp, chn, NULL, 1); struct htx *htx = smp_prefetch_htx(smp, chn, NULL, 1);
if (!args || args->type != ARGT_USR) if (args->type != ARGT_USR)
return 0; return 0;
if (!htx) if (!htx)
@ -1396,7 +1392,7 @@ static int smp_fetch_capture_req_hdr(const struct arg *args, struct sample *smp,
struct proxy *fe; struct proxy *fe;
int idx; int idx;
if (!args || args->type != ARGT_SINT) if (args->type != ARGT_SINT)
return 0; return 0;
if (!smp->strm) if (!smp->strm)
@ -1424,7 +1420,7 @@ static int smp_fetch_capture_res_hdr(const struct arg *args, struct sample *smp,
struct proxy *fe; struct proxy *fe;
int idx; int idx;
if (!args || args->type != ARGT_SINT) if (args->type != ARGT_SINT)
return 0; return 0;
if (!smp->strm) if (!smp->strm)
@ -1588,7 +1584,7 @@ static int smp_fetch_cookie(const struct arg *args, struct sample *smp, const ch
size_t cook_l = 0; size_t cook_l = 0;
int found = 0; int found = 0;
if (args && args->type == ARGT_STR) { if (args->type == ARGT_STR) {
cook = args->data.str.area; cook = args->data.str.area;
cook_l = args->data.str.data; cook_l = args->data.str.data;
} }
@ -1690,7 +1686,7 @@ static int smp_fetch_cookie_cnt(const struct arg *args, struct sample *smp, cons
size_t cook_l = 0; size_t cook_l = 0;
int cnt; int cnt;
if (args && args->type == ARGT_STR){ if (args->type == ARGT_STR){
cook = args->data.str.area; cook = args->data.str.area;
cook_l = args->data.str.data; cook_l = args->data.str.data;
} }
@ -1816,8 +1812,7 @@ static int smp_fetch_url_param(const struct arg *args, struct sample *smp, const
const char *name; const char *name;
int name_len; int name_len;
if (!args || if ((args[0].type && args[0].type != ARGT_STR) ||
(args[0].type && args[0].type != ARGT_STR) ||
(args[1].type && args[1].type != ARGT_STR)) (args[1].type && args[1].type != ARGT_STR))
return 0; return 0;
@ -1868,7 +1863,7 @@ static int smp_fetch_body_param(const struct arg *args, struct sample *smp, cons
const char *name; const char *name;
int name_len; int name_len;
if (!args || (args[0].type && args[0].type != ARGT_STR)) if (args[0].type && args[0].type != ARGT_STR)
return 0; return 0;
name = ""; name = "";