diff options
author | Alan Cox <alc@FreeBSD.org> | 2003-11-13 05:26:55 +0000 |
---|---|---|
committer | Alan Cox <alc@FreeBSD.org> | 2003-11-13 05:26:55 +0000 |
commit | b9e25f436bd5f90764909794a7bc450bfd8d1f3c (patch) | |
tree | 27152bd757f1ebe7d74ab5221256a0b8e6df8d91 /bin/cp | |
parent | 93685685f4219bccc7aff5df50f41893d89e8c22 (diff) | |
download | src-b9e25f436bd5f90764909794a7bc450bfd8d1f3c.tar.gz src-b9e25f436bd5f90764909794a7bc450bfd8d1f3c.zip |
Don't mmap(2) and munmap(2) zero-length files.
Submitted by: Wiktor Niesiobedzki <bsd@w.evip.pl>
Notes
Notes:
svn path=/head/; revision=122601
Diffstat (limited to 'bin/cp')
-rw-r--r-- | bin/cp/utils.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/bin/cp/utils.c b/bin/cp/utils.c index e8c542c7d004..782dc6becb07 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); |