Skip to content

Commit

Permalink
MINOR: cfgparse-quic: strengthen quic-cc-algo parsing
Browse files Browse the repository at this point in the history
quic-cc-algo is a bind keyword which is used to specify the congestion
control algorithm. It is parsed via function bind_parse_quic_cc_algo().

The parsing function was too laxed as it used strncmp for algo token
matching. This could cause surprise if specifying an invalid algorithm
but starting identically to another entry. Especially if extra
parameters are specified in parenthesis, as in this case parameters
value will be completely ignored and default value used instead.

To fix this, convert algo argument to ist. Then, use istsplit() to
extract algo token from the optional extra arguments and compare the
whole value with isteq().
  • Loading branch information
a-denoyelle committed Nov 25, 2024
1 parent 3500865 commit d41273c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/cfgparse-quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ static int bind_parse_quic_cc_algo(char **args, int cur_arg, struct proxy *px,
{
struct quic_cc_algo *cc_algo = NULL;
const char *algo = NULL;
struct ist algo_ist, arg_ist;
char *arg;

cc_algo = calloc(1, sizeof(struct quic_cc_algo));
Expand All @@ -116,19 +117,21 @@ static int bind_parse_quic_cc_algo(char **args, int cur_arg, struct proxy *px,
}

arg = args[cur_arg + 1];
if (strncmp(arg, QUIC_CC_NEWRENO_STR, strlen(QUIC_CC_NEWRENO_STR)) == 0) {
arg_ist = ist(args[cur_arg + 1]);
algo_ist = istsplit(&arg_ist, '(');
if (isteq(algo_ist, ist(QUIC_CC_NEWRENO_STR))) {
/* newreno */
algo = QUIC_CC_NEWRENO_STR;
*cc_algo = quic_cc_algo_nr;
arg += strlen(QUIC_CC_NEWRENO_STR);
}
else if (strncmp(arg, QUIC_CC_CUBIC_STR, strlen(QUIC_CC_CUBIC_STR)) == 0) {
else if (isteq(algo_ist, ist(QUIC_CC_CUBIC_STR))) {
/* cubic */
algo = QUIC_CC_CUBIC_STR;
*cc_algo = quic_cc_algo_cubic;
arg += strlen(QUIC_CC_CUBIC_STR);
}
else if (strncmp(arg, QUIC_CC_BBR_STR, strlen(QUIC_CC_BBR_STR)) == 0) {
else if (isteq(algo_ist, ist(QUIC_CC_BBR_STR))) {
if (!experimental_directives_allowed) {
ha_alert("'%s' algo is experimental, must be allowed via a global "
"'expose-experimental-directives'\n", arg);
Expand All @@ -140,7 +143,7 @@ static int bind_parse_quic_cc_algo(char **args, int cur_arg, struct proxy *px,
*cc_algo = quic_cc_algo_bbr;
arg += strlen(QUIC_CC_BBR_STR);
}
else if (strncmp(arg, QUIC_CC_NO_CC_STR, strlen(QUIC_CC_NO_CC_STR)) == 0) {
else if (isteq(algo_ist, ist(QUIC_CC_NO_CC_STR))) {
/* nocc */
if (!experimental_directives_allowed) {
ha_alert("'%s' algo is experimental, must be allowed via a global "
Expand Down

0 comments on commit d41273c

Please sign in to comment.