Skip to content

Commit

Permalink
Fix missing return values and some error tests for empty index files
Browse files Browse the repository at this point in the history
Patches from Dave Jones and Ingo Molnar, but since I don't have any
infrastructure in place to use the old patch applicator scripts I
am trying to build up, I ended up fixing the thing by hand instead.

Credit where credit is due, though. Nice to see that people are
taking a look at the project even in this early stage.
  • Loading branch information
Linus Torvalds committed Apr 9, 2005
1 parent 1ea34e3 commit 59c1e24
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct cache_entry {
unsigned int st_size;
unsigned char sha1[20];
unsigned short namelen;
unsigned char name[0];
char name[0];
};

const char *sha1_file_directory;
Expand Down
2 changes: 2 additions & 0 deletions fsck-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ static int fsck_tree(unsigned char *sha1, void *data, unsigned long size)
size -= len + 20;
mark_needs_sha1(sha1, "blob", file_sha1);
}
return 0;
}

static int fsck_commit(unsigned char *sha1, void *data, unsigned long size)
Expand All @@ -49,6 +50,7 @@ static int fsck_commit(unsigned char *sha1, void *data, unsigned long size)
mark_needs_sha1(sha1, "commit", parent_sha1);
data += 7 + 40 + 1; /* "parent " + <hex sha1> + '\n' */
}
return 0;
}

static int fsck_entry(unsigned char *sha1, char *tag, void *data, unsigned long size)
Expand Down
3 changes: 1 addition & 2 deletions read-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,9 @@ int read_cache(void)
size = 0; // avoid gcc warning
map = (void *)-1;
if (!fstat(fd, &st)) {
map = NULL;
size = st.st_size;
errno = EINVAL;
if (size > sizeof(struct cache_header))
if (size >= sizeof(struct cache_header))
map = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
}
close(fd);
Expand Down

0 comments on commit 59c1e24

Please sign in to comment.