This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/21270] mmap64 silently truncates large offset values


https://sourceware.org/bugzilla/show_bug.cgi?id=21270

--- Comment #3 from Thiago Macieira <thiago at kde dot org> ---
(In reply to Szabolcs Nagy from comment #2)
> posix allows EINVAL if ".. off is not a multiple of the page size as
> returned by sysconf(), or is considered invalid by the implementation".
> 
> so EINVAL is conforming too, silently truncating is not. (musl libc uses
> EINVAL).

EINVAL would indeed be better.

You're also right, musl does check for invalid size. I had missed the
definition of the OFF_MASK that includes the bits for 1<<44 and higher. They
have a weird definition of it:

#define OFF_MASK ((-0x2000ULL << (8*sizeof(long)-1)) | (UNIT-1))

Instead of -0x2000ULL and shifting left by the number of bits in long minus
one, I'd have done -0x1000ULL (which is a page) and shift left by the number of
bits.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]