Skip to contentSkip to conversation

compat: make sure git_mmap is not expected to write

PATCH Superseded carlo 3 participants 4 messages Oct 23, 2018 – Oct 24, 2018

lore
Share & tools
lore

carlo

author
#0 lore raw

PATCH 1/1 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)

---
 compat/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
compat/mmap.c +1 -1
index 7f662fef7b..14d31010df 100644
@@ -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);
Signature · 1 line
2.19.1
#1 lore raw

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?

Quoted 5 lines · carlo

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)

ACK!

Thank you,
Johannes

Quoted 21 lines
---
 compat/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
compat/mmap.c +1 -1
index 7f662fef7b..14d31010df 100644
@@ -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);
Signature · 1 line
2.19.1
#2 lore raw

PATCH v2 1/1 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

---
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(-)
compat/mmap.c +1 -1
index 7f662fef7b..14d31010df 100644
@@ -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);
Signature · 1 line
2.19.1
#3 lore raw
Quoted 11 lines · Carlo Marcelo Arenas Belón

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

---
Changes in v2:

* reset-author to match signature
* cleanup commit message and add ACK

Thanks. Looking good.

Quoted 16 lines
 compat/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
compat/mmap.c +1 -1
index 7f662fef7b..14d31010df 100644
@@ -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);