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

The uint48 functions are both broken #79

Open
talex5 opened this issue Jan 30, 2023 · 0 comments
Open

The uint48 functions are both broken #79

talex5 opened this issue Jan 30, 2023 · 0 comments

Comments

@talex5
Copy link

talex5 commented Jan 30, 2023

(reported against Eio in ocaml-multicore/eio#418, which contains fixes and tests)

faraday/lib/faraday.ml

Lines 290 to 297 in c66fc02

let write_uint48 t i =
writable_exn t;
ensure_space t 6;
Bigstringaf.unsafe_set_int32_be t.buffer t.write_pos
Int64.(to_int32 (shift_right_logical i 4));
Bigstringaf.unsafe_set_int16_be t.buffer (t.write_pos + 2)
Int64.(to_int i);
t.write_pos <- t.write_pos + 6

@adatario noticed that the shifts should be in bits, not bytes.

Also, the BE version gets the sizes of the chunks wrong (should be 16 then 32).

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

No branches or pull requests

1 participant