Merge branch 'cb/compat-mmap-is-private-read-only'
authorJunio C Hamano <gitster@pobox.com>
Tue, 30 Oct 2018 06:43:49 +0000 (15:43 +0900)
committerJunio C Hamano <gitster@pobox.com>
Tue, 30 Oct 2018 06:43:49 +0000 (15:43 +0900)
Code tightening.

* cb/compat-mmap-is-private-read-only:
compat: make sure git_mmap is not expected to write

compat/mmap.c
index 7f662fef7bcb408045eb1536afed058a607ae97b..14d31010dfe57e520c6864df4f84ea732018785f 100644 (file)
@@ -4,7 +4,7 @@ void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t of
 {
        size_t n = 0;
 
-       if (start != NULL || !(flags & MAP_PRIVATE))
+       if (start != NULL || flags != MAP_PRIVATE || prot != PROT_READ)
                die("Invalid usage of mmap when built with NO_MMAP");
 
        start = xmalloc(length);