From 5bdb94b83897181357935dfd40c365aa2a5300ac Mon Sep 17 00:00:00 2001 From: alc Date: Thu, 13 Nov 2003 05:26:55 +0000 Subject: Don't mmap(2) and munmap(2) zero-length files. Submitted by: Wiktor Niesiobedzki --- bin/cp/utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/cp/utils.c b/bin/cp/utils.c index e8c542c..782dc6b 100644 --- a/bin/cp/utils.c +++ b/bin/cp/utils.c @@ -133,7 +133,8 @@ copy_file(const FTSENT *entp, int dne) * wins some CPU back. */ #ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED - if (S_ISREG(fs->st_mode) && fs->st_size <= 8 * 1048576) { + if (S_ISREG(fs->st_mode) && fs->st_size > 0 && + fs->st_size <= 8 * 1048576) { if ((p = mmap(NULL, (size_t)fs->st_size, PROT_READ, MAP_SHARED, from_fd, (off_t)0)) == MAP_FAILED) { warn("%s", entp->fts_path); -- cgit v1.1