threads / patch / 49644

patchcompat: make sure git_mmap is not expected to write

Subject: [PATCH] compat: make sure git_mmap is not expected to write

## tl;dr

4 messages between Oct 23, 2018 and Oct 24, 2018. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

carlo· Oct 23, 2018, 05:12 UTC · lore

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>
---
 compat/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to compat/mmap.c +1 −1
diff --git a/compat/mmap.c b/compat/mmap.c
index 7f662fef7b..14d31010df 100644
--- a/compat/mmap.c
+++ b/compat/mmap.c
@@ -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);
-- 
2.19.1
Johannes Schindelin· Oct 23, 2018, 10:13 UTC · re: carlo · lore

Re: [PATCH] compat: make sure git_mmap is not expected to write

Hi carlo,
your mail's "From:" line does not record your full name, but the
Signed-off-by: line does. Let's use the latter?
On Mon, 22 Oct 2018, carlo wrote:
Show 5 quoted lines
> 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>
ACK!

Thank you, Johannes

Show 21 quoted lines
> ---
>  compat/mmap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/compat/mmap.c b/compat/mmap.c
> index 7f662fef7b..14d31010df 100644
> --- a/compat/mmap.c
> +++ b/compat/mmap.c
> @@ -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);
> -- 
> 2.19.1
> 
> 
Carlo Marcelo Arenas Belón· Oct 23, 2018, 12:35 UTC · re: Johannes Schindelin · lore

[PATCH v2] compat: make sure git_mmap is not expected to write

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

Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
Changes in v2:
    
* reset-author to match signature
* cleanup commit message and add ACK
 compat/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to compat/mmap.c +1 −1
diff --git a/compat/mmap.c b/compat/mmap.c
index 7f662fef7b..14d31010df 100644
--- a/compat/mmap.c
+++ b/compat/mmap.c
@@ -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);
-- 
2.19.1
Junio C Hamano· Oct 24, 2018, 01:43 UTC · re: Carlo Marcelo Arenas Belón · lore

Re: [PATCH v2] compat: make sure git_mmap is not expected to write

Carlo Marcelo Arenas Belón  <carenas@gmail.com> writes:
Show 11 quoted lines
> 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
>
> Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> ---
> Changes in v2:
>     
> * reset-author to match signature
> * cleanup commit message and add ACK
Thanks.  Looking good.
Show 16 quoted lines
>  compat/mmap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/compat/mmap.c b/compat/mmap.c
> index 7f662fef7b..14d31010df 100644
> --- a/compat/mmap.c
> +++ b/compat/mmap.c
> @@ -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);

← back to recent threads