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

Fail when unmarshaling would produce non-canonical big integers #149

Merged
merged 3 commits into from
Jan 3, 2024

Conversation

xavierleroy
Copy link
Contributor

@xavierleroy xavierleroy commented Dec 11, 2023

As reported in #148, big integers marshaled on a 32-bit platform (or by JS-of-OCaml) and unmarshaled on a 64-bit platform can appear as custom blocks while the 64-bit platform expects a tagged OCaml integer. This can produce wrong results in many different ways.

This PR proposes to fail during unmarshaling in this case. The failure is obtained by returning a wrong length for the big integer. In current OCaml the error message is strange (Failure "input_value: incorrect length of serialized custom block") but I have a companion PR to improve it a bit.

Fixes: #148

@xavierleroy
Copy link
Contributor Author

Oups, bizarre closing. Reopening.

@xavierleroy xavierleroy reopened this Dec 12, 2023
@xavierleroy
Copy link
Contributor Author

I feel confident enough about this change to merge it right now.

@xavierleroy xavierleroy merged commit d0a89ee into ocaml:master Jan 3, 2024
8 checks passed
@xavierleroy xavierleroy deleted the cautious-unmarshaling branch January 3, 2024 13:17
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 this pull request may close these issues.

Non-canonical values when deserializing large integers from 32 bits arch on a 64 bits arch
1 participant