Farid Zaripov wrote:
[...]
  Windows grant read access with write and execute access rights except
PAGE_NOACCESS.
SuSe Linux grant read access with execute access.
I think Solaris 9 grant read access only when PROT_READ is specified
explicitly.

I see.


http://www.opengroup.org/onlinepubs/009695399/functions/mmap.html says
that guaranteed only:
- no write access if PROT_WRITE is not specified;
- no any access if prot == PROT_NONE.
[...]
  I see two ways to resolve these asserts:

1) add #elif defined (__linux__) guarded code (see below)

        bool canread = (tcase.prot_ &
#if defined (_WIN32) || defined (_WIN64)
               (RW_PROT_READ | RW_PROT_WRITE | RW_PROT_EXEC))
#elif defined (__linux__)
               (RW_PROT_READ | RW_PROT_EXEC))
#else
               (RW_PROT_READ)
#endif
            && (
                (protbelow && 0 <= tcase.index_)
             || (!protbelow && tcase.index_ < int (tcase.size_))
            );

2) remove check of read access if RW_PROT_READ is not specified
explicitly

Going by what POSIX says and avoiding any assumptions beyond it
sounds like the way to go to me. In addition, since PROT_EXEC
isn't really being tested I'm wondering if we should remove it.
Can you think of any way to use it for anything?

Martin

Reply via email to