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

Fixed base64 decoding in mruby-pack #6243

Merged
merged 1 commit into from Apr 20, 2024
Merged

Fixed base64 decoding in mruby-pack #6243

merged 1 commit into from Apr 20, 2024

Conversation

dearblue
Copy link
Contributor

Previously \x80 was incorrectly mapped to 0.

"\x80\x80\x80\x80".unpack("m*")
# before => "\x00\x00\x00"
# after  => ""

The reason is that the C string terminator is placed in base64_dec_tab[128] and the array length is obtained by sizeof. Therefore, the length of base64_dec_tab[] is strictly specified and replaced with element-by-element initialization.

Also, similar changes are made to base64chars[].

Previously `\x80` was incorrectly mapped to `0`.

```ruby
"\x80\x80\x80\x80".unpack("m*")
# before => "\x00\x00\x00"
# after  => ""
```

The reason is that the C string terminator is placed in `base64_dec_tab[128]` and the array length is obtained by `sizeof`.
Therefore, the length of `base64_dec_tab[]` is strictly specified and replaced with element-by-element initialization.

Also, similar changes are made to `base64chars[]`.
@dearblue dearblue requested a review from matz as a code owner April 20, 2024 01:01
@matz matz merged commit ad476c3 into mruby:master Apr 20, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants