Skip to content

Commit

Permalink
Fixed delta updates bug wherein updates fail on empty file.
Browse files Browse the repository at this point in the history
mmap()ing empty files caused EINVAL to be returned and _hashOfFile
would return an incorrect result. This has been rectified.
  • Loading branch information
aidansteele authored and andymatuschak committed Aug 24, 2010
1 parent a8f26b1 commit e2a59fc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions SUBinaryDeltaCommon.m
Expand Up @@ -78,6 +78,11 @@ static void _hashOfFile(unsigned char* hash, FTSENT *ent)
}

size_t fileSize = (size_t)ent->fts_statp->st_size;
if (fileSize == 0) {
_hashOfBuffer(hash, NULL, 0);
return;
}

void *buffer = mmap(0, fileSize, PROT_READ, MAP_FILE | MAP_PRIVATE, fileDescriptor, 0);
if (buffer == (void*)-1) {
close(fileDescriptor);
Expand Down

0 comments on commit e2a59fc

Please sign in to comment.