aboutsummaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2006-11-15 17:27:54 +0100
committerJunio C Hamano <junkio@cox.net>2006-11-15 10:23:47 -0800
commit0a3881d4cfee5c4ee3991a1b14a10333355958f1 (patch)
tree2e924a69d1ebc0c3a3e3f18fb7d34e68c23271e9 /compat
parente267c2f6f0784e242883b7d3fe5f36ef63d6950d (diff)
downloadgit-0a3881d4cfee5c4ee3991a1b14a10333355958f1.tar.gz
git-0a3881d4cfee5c4ee3991a1b14a10333355958f1.tar.xz
Seek back to current filepos when mmap()ing with NO_MMAP
"git-index-pack --fix-thin" relies on mmap() not changing the current file position (otherwise the pack will be corrupted when writing the final SHA1). Meet that expectation. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'compat')
-rw-r--r--compat/mmap.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/compat/mmap.c b/compat/mmap.c
index 55cb12076..a4d2e507f 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;
}