diff options
author | Stefan Sperling <stsp@openbsd.org> | 2014-11-03 13:46:56 +0100 |
---|---|---|
committer | Carlos MartÃn Nieto <cmn@dwim.me> | 2014-11-03 15:06:44 +0100 |
commit | 9c0463530d8e96d08e7c87e5a5d07949ea71b77c (patch) | |
tree | 8069e6a50c7f046f238fbd32cc2292f9f0d6165b | |
parent | 4af08d9f69f151f6362df51d7d7f41527e2af05c (diff) | |
download | libgit2-9c0463530d8e96d08e7c87e5a5d07949ea71b77c.tar.gz |
Fix segmentation fault observed on OpenBSD/sparc64
A non-readable mapping of a file causes an access violation in
the pack tests. Always use PROT_READ to work around this.
-rw-r--r-- | src/unix/map.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/unix/map.c b/src/unix/map.c index 3d0cbbaf8..2965d8651 100644 --- a/src/unix/map.c +++ b/src/unix/map.c @@ -20,7 +20,7 @@ long git__page_size(void) 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); @@ -29,9 +29,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; |