Skip to content

Commit 20e022e

Browse files
committed
[core] fix jwt verify
1 parent ba551d4 commit 20e022e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/switch_utils.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -4978,6 +4978,7 @@ SWITCH_DECLARE(cJSON *) switch_jwt_verify(const char *secret, const char *token)
49784978
dot++; // signature
49794979
out = (char *)switch_must_malloc(strlen(dot) + 1);
49804980
len = switch_b64_decode((const char *)dot, out, strlen(dot) + 1);
4981+
len--; // the len is always 1 byte more than the actual length
49814982
if (len != SHA256_LENGTH) goto end;
49824983
ok = !memcmp(out, signature, len);
49834984
free(out);
@@ -4989,7 +4990,7 @@ SWITCH_DECLARE(cJSON *) switch_jwt_verify(const char *secret, const char *token)
49894990
if (p) {
49904991
p++;
49914992
out = (char *)switch_must_malloc(strlen(p));
4992-
len = switch_b64_decode((const char *)p, out, strlen(p));
4993+
switch_b64_decode((const char *)p, out, strlen(p));
49934994
payload = cJSON_Parse(out);
49944995
free(out);
49954996
out = NULL;

0 commit comments

Comments
 (0)