Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in base64url decoding algorithm - undefined length #20616

Closed
tmcw opened this issue Sep 21, 2023 · 1 comment · Fixed by #20648
Closed

Bug in base64url decoding algorithm - undefined length #20616

tmcw opened this issue Sep 21, 2023 · 1 comment · Fixed by #20648
Assignees

Comments

@tmcw
Copy link

tmcw commented Sep 21, 2023

Looks like this is here:

src = src.subarray(0, length);

And was introduced recently in #20158

blitBuffer refers to length, which isn't a local variable was probably intended to be byteLength or src.length. Testcase for this bug:

Deno 1.37.0
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run `deno repl` with allow flags.
> import { Buffer } from "node:buffer"
undefined
> Buffer.from('ZmRzYWZkYWZkc2E', 'base64url')
Uncaught ReferenceError: length is not defined
    at blitBuffer (ext:deno_node/internal/buffer.mjs:1778:27)
    at Uint8Array.base64urlWrite (ext:deno_node/internal/buffer.mjs:691:10)
    at Object.write (ext:deno_node/internal/buffer.mjs:2194:11)
    at Uint8Array.write (ext:deno_node/internal/buffer.mjs:794:14)
    at fromString (ext:deno_node/internal/buffer.mjs:214:22)
    at _from (ext:deno_node/internal/buffer.mjs:119:12)
    at Function.from (ext:deno_node/internal/buffer.mjs:157:10)
    at <anonymous>:2:8

This might be the root cause of #20563

@bartlomieju
Copy link
Member

@aapoalas could you take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants