]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: jwt: Wrong return value checked
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Fri, 20 Jan 2023 08:37:26 +0000 (09:37 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Fri, 20 Jan 2023 09:27:37 +0000 (10:27 +0100)
The wrong return value was checked, resulting in dead code and
potential bugs.

It should fix GitHub issue #2005.
This patch should be backported up to 2.5.

reg-tests/jwt/jws_verify.vtc
src/jwt.c

index 3aaf8d8b764a278361ad018588055a7dc7a39b78..d9a6328f3d8ace8462ee29350b74179e949cf146 100644 (file)
@@ -265,7 +265,8 @@ client c12 -connect ${h1_mainfe_sock} {
     rxresp
     expect resp.status == 200
     expect resp.http.x-jwt-alg == "ES512"
-    expect resp.http.x-jwt-verify-ES512 == "0"
+    # Invalid token
+    expect resp.http.x-jwt-verify-ES512 == "-3"
 } -run
 
 
index a17af18476af7d825cc6347d5f0a22f799ac5e0e..b901588dbf96b9286d97fc1e29234012ad5f3913 100644 (file)
--- a/src/jwt.c
+++ b/src/jwt.c
@@ -331,7 +331,7 @@ jwt_jwsverify_rsa_ecdsa(const struct jwt_ctx *ctx, struct buffer *decoded_signat
         */
        if (is_ecdsa) {
                int conv_retval = convert_ecdsa_sig(ctx, entry->pkey, decoded_signature);
-               if (retval != 0) {
+               if (conv_retval != 0) {
                        retval = conv_retval;
                        goto end;
                }