mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-08 20:41:59 +03:00
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:
parent
25d5ed8c6a
commit
8c441fdd12
@ -719,6 +719,9 @@ static int compare_files (char *name1, char *name2, off_t size)
|
|||||||
int file1, file2;
|
int file1, file2;
|
||||||
int result = -1; /* Different by default */
|
int result = -1; /* Different by default */
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
file1 = open (name1, O_RDONLY);
|
file1 = open (name1, O_RDONLY);
|
||||||
if (file1 >= 0){
|
if (file1 >= 0){
|
||||||
file2 = open (name2, O_RDONLY);
|
file2 = open (name2, O_RDONLY);
|
||||||
|
Loading…
Reference in New Issue
Block a user