summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2014-11-03 14:52:34 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2014-11-03 14:52:34 +0100
commit0fab748e9184fdf2f1fee832acf0e81cb46e44b1 (patch)
tree5acc4b34a968eec321a6c2de65d9d6665028e405
parent2cc6011e69ae9fd141dfcd3533f703096758b922 (diff)
parentaad0bd6bc78b79bb8c0778c0c135c167d359fe12 (diff)
downloadlibgit2-0fab748e9184fdf2f1fee832acf0e81cb46e44b1.tar.gz
Merge pull request #2685 from libgit2/cmn/mmap-readable
Fix segmentation fault observed on OpenBSD/sparc64
-rw-r--r--src/unix/map.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/unix/map.c b/src/unix/map.c
index 0a235d5a1..87ee6594b 100644
--- a/src/unix/map.c
+++ b/src/unix/map.c
@@ -26,7 +26,7 @@ int git__page_size(size_t *page_size)
int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset)
{
- int mprot = 0;
+ int mprot = PROT_READ;
int mflag = 0;
GIT_MMAP_VALIDATE(out, len, prot, flags);
@@ -35,9 +35,7 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
out->len = 0;
if (prot & GIT_PROT_WRITE)
- mprot = PROT_WRITE;
- else if (prot & GIT_PROT_READ)
- mprot = PROT_READ;
+ mprot |= PROT_WRITE;
if ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED)
mflag = MAP_SHARED;