BUG/MINOR: jwt: Fix jwt_parse_alg incorrectly returning JWS_ALG_NONE

jwt_parse_alg would mistakenly return JWT_ALG_NONE for algorithms "",
"n", "no" and "non" because of a strncmp misuse. It now sees them as
unknown algorithms.

No backport needed.

Cc: Tim Duesterhus <tim@bastelstu.be>
This commit is contained in:
Remi Tricot-Le Breton 2021-11-03 12:23:54 +01:00 committed by Willy Tarreau
parent f8642ee826
commit 7266350181
1 changed files with 1 additions and 1 deletions

View File

@ -34,7 +34,7 @@ enum jwt_alg jwt_parse_alg(const char *alg_str, unsigned int alg_len)
/* Algorithms are all 5 characters long apart from "none". */
if (alg_len < sizeof("HS256")-1) {
if (strncmp("none", alg_str, alg_len) == 0)
if (alg_len == sizeof("none")-1 && strcmp("none", alg_str) == 0)
alg = JWS_ALG_NONE;
return alg;
}