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
This commit is contained in:
Slava Zanko 2009-05-12 10:03:32 +03:00
parent 25d5ed8c6a
commit 8c441fdd12

View File

@ -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);