From e2a59fccb26c6b4572ebe55e450b74c0a006533b Mon Sep 17 00:00:00 2001 From: aidansteele Date: Mon, 23 Aug 2010 16:52:42 +0800 Subject: [PATCH] Fixed delta updates bug wherein updates fail on empty file. mmap()ing empty files caused EINVAL to be returned and _hashOfFile would return an incorrect result. This has been rectified. --- SUBinaryDeltaCommon.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SUBinaryDeltaCommon.m b/SUBinaryDeltaCommon.m index e4f9ed6f..43e31912 100644 --- a/SUBinaryDeltaCommon.m +++ b/SUBinaryDeltaCommon.m @@ -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);