summaryrefslogtreecommitdiff
path: root/local-pull.c
diff options
context:
space:
mode:
authorPavel Roskin <proski@gnu.org>2005-07-29 14:49:14 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-07-30 00:21:48 (GMT)
commite35f9824159bba94eecdf22d198799701ed60940 (patch)
tree0d1d08eec92d179ce02b4c4b5e961e0f6c1feddc /local-pull.c
parent1df092d211868b3b74f5b3981fad9b195a0bedad (diff)
downloadgit-e35f9824159bba94eecdf22d198799701ed60940.zip
git-e35f9824159bba94eecdf22d198799701ed60940.tar.gz
git-e35f9824159bba94eecdf22d198799701ed60940.tar.bz2
[PATCH] mmap error handling
I have reviewed all occurrences of mmap() in git and fixed three types of errors/defects: 1) The result is not checked. 2) The file descriptor is closed if mmap() succeeds, but not when it fails. 3) Various casts applied to -1 are used instead of MAP_FAILED, which is specifically defined to check mmap() return value. [jc: This is a second round of Pavel's patch. He fixed up the problem that close() potentially clobbering the errno from mmap, which the first round had.] Signed-off-by: Pavel Roskin <proski@gnu.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'local-pull.c')
-rw-r--r--local-pull.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/local-pull.c b/local-pull.c
index 2f06fbe..908e187 100644
--- a/local-pull.c
+++ b/local-pull.c
@@ -54,7 +54,7 @@ int fetch(unsigned char *sha1)
}
map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, ifd, 0);
close(ifd);
- if (-1 == (int)(long)map) {
+ if (map == MAP_FAILED) {
fprintf(stderr, "cannot mmap %s\n", filename);
return -1;
}