summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compat/mmap.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/compat/mmap.c b/compat/mmap.c
index 55cb120764..a4d2e507f7 100644
--- a/compat/mmap.c
+++ b/compat/mmap.c
@@ -7,6 +7,7 @@
void *gitfakemmap(void *start, size_t length, int prot , int flags, int fd, off_t offset)
{
int n = 0;
+ off_t current_offset = lseek(fd, 0, SEEK_CUR);
if (start != NULL || !(flags & MAP_PRIVATE))
die("Invalid usage of gitfakemmap.");
@@ -39,6 +40,11 @@ void *gitfakemmap(void *start, size_t length, int prot , int flags, int fd, off_
n += count;
}
+ if (current_offset != lseek(fd, current_offset, SEEK_SET)) {
+ errno = EINVAL;
+ return MAP_FAILED;
+ }
+
return start;
}