Skip to content

The uint48 functions are both broken #79

@talex5

Description

@talex5

(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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions