From 8c441fdd1205448ef763814366691f65fb10302d Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Tue, 12 May 2009 10:03:32 +0300 Subject: [PATCH] src/cmd.c: Fixed bug was caused by mmap behaviour when length = 0 Here is quote from man(3) mmap: SUSv3 specifies that mmap() should fail if length is 0. However, in kernels before 2.6.12, mmap() succeeded in this case: no mapping was created and the call returned addr. Since kernel 2.6.12, mmap() fails with the error EINVAL for this case. Thanks to snizovtsev --- src/cmd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cmd.c b/src/cmd.c index 2548bfa1e..36dd8ad05 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -719,6 +719,9 @@ static int compare_files (char *name1, char *name2, off_t size) int file1, file2; int result = -1; /* Different by default */ + if (size == 0) + return 0; + file1 = open (name1, O_RDONLY); if (file1 >= 0){ file2 = open (name2, O_RDONLY);