提交 0a3881d4 编写于 作者: J Johannes Schindelin 提交者: Junio C Hamano

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: NJohannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: NJunio C Hamano <junkio@cox.net>
上级 e267c2f6
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册