memmap-rs icon indicating copy to clipboard operation
memmap-rs copied to clipboard

avoid silently truncating the offset

Open oconnor663 opened this issue 7 years ago • 2 comments

This should address one of the concerns that came up in https://github.com/danburkert/memmap-rs/pull/65.

I'm not sure exactly what test I should add for this case. Please advise :)

oconnor663 avatar Sep 20 '18 05:09 oconnor663

I expected that the fix to this would be to use mmap64 instead of mmap (on select platforms), or is that infeasible?

danburkert avatar Oct 02 '18 05:10 danburkert

That definitely sounds like the better fix where it's possible, but I don't know how wide mmap64 support is. The libc crate doesn't seem to support it for macOS or any of the other BSD variants. Do you think we should start calling that function on Linux, as part of this PR? A couple of thoughts:

  • Because off64_t is an i64, but our offset parameter is a u64, we'll still need to check for overflow when we cast it.
  • It looks like emscripten perversely defines off64_t as i32. I assume mmap fails under emscripten anyway, but if there might be more platforms in the future doing this, we might not want to assume off64_t is actually always 64 bits.

oconnor663 avatar Oct 03 '18 16:10 oconnor663