]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: sample/jwt: fix another instance of base64 error detection
authorWilly Tarreau <w@1wt.eu>
Fri, 15 Oct 2021 10:10:24 +0000 (12:10 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 15 Oct 2021 10:14:16 +0000 (12:14 +0200)
This is the same as for commit 468c000db ("BUG/MEDIUM: jwt: fix base64
decoding error detection"), but for function sample_conv_jwt_member_query()
that is used by sample converters jwt_header_query() and jwt_payload_query().
Thanks to Tim for the report. No backport is needed.

src/sample.c

index de45245e939c32ac564b67f4ea837a60677771ff..47ccfbb0b364026a8e1f93493c5cdfaaeaec0c5c 100644 (file)
@@ -3561,6 +3561,7 @@ static int sample_conv_jwt_member_query(const struct arg *args, struct sample *s
        unsigned int item_num = member + 1; /* We don't need to tokenize the full token */
        struct buffer *decoded_header = get_trash_chunk();
        int retval = 0;
+       int ret;
 
        jwt_tokenize(&smp->data.u.str, items, &item_num);
 
@@ -3571,12 +3572,12 @@ static int sample_conv_jwt_member_query(const struct arg *args, struct sample *s
        if (!decoded_header)
                goto end;
 
-       decoded_header->data = base64urldec(items[member].start, items[member].length,
-                                           decoded_header->area, decoded_header->size);
-
-       if (decoded_header->data == (unsigned int)-1)
+       ret = base64urldec(items[member].start, items[member].length,
+                          decoded_header->area, decoded_header->size);
+       if (ret == -1)
                goto end;
 
+       decoded_header->data = ret;
        if (args[0].type != ARGT_STR) {
                smp->data.u.str = *decoded_header;
                smp->data.type = SMP_T_STR;