]> git.ipfire.org Git - thirdparty/git.git/commitdiff
compat: make sure git_mmap is not expected to write
authorCarlo Marcelo Arenas Belón <carenas@gmail.com>
Tue, 23 Oct 2018 12:35:19 +0000 (05:35 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 25 Oct 2018 09:51:03 +0000 (18:51 +0900)
in f48000fc ("Yank writing-back support from gitfakemmap.", 2005-10-08)
support for writting back changes was removed but the specific prot
flag that would be used was not checked for

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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);