Skip to content

Commit

Permalink
[core] fix jwt verify
Browse files Browse the repository at this point in the history
  • Loading branch information
seven1240 committed Nov 28, 2024
1 parent ba551d4 commit 20e022e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/switch_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -4978,6 +4978,7 @@ SWITCH_DECLARE(cJSON *) switch_jwt_verify(const char *secret, const char *token)
dot++; // signature
out = (char *)switch_must_malloc(strlen(dot) + 1);
len = switch_b64_decode((const char *)dot, out, strlen(dot) + 1);
len--; // the len is always 1 byte more than the actual length
if (len != SHA256_LENGTH) goto end;
ok = !memcmp(out, signature, len);
free(out);
Expand All @@ -4989,7 +4990,7 @@ SWITCH_DECLARE(cJSON *) switch_jwt_verify(const char *secret, const char *token)
if (p) {
p++;
out = (char *)switch_must_malloc(strlen(p));
len = switch_b64_decode((const char *)p, out, strlen(p));
switch_b64_decode((const char *)p, out, strlen(p));
payload = cJSON_Parse(out);
free(out);
out = NULL;
Expand Down

0 comments on commit 20e022e

Please sign in to comment.