From f9ae8c45d6268157d4e25dcaba9ec67c17d82d8c Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Thu, 12 Aug 1999 22:11:08 +0000 Subject: [PATCH] (copy_stream): avoid calling mmap with `len == 0'. Some mmap:s rather dislike that (Solaris) and some munmap get grumpy later. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6803 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/ftp/ftp/ftp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/appl/ftp/ftp/ftp.c b/appl/ftp/ftp/ftp.c index 142d43f3b..770c50590 100644 --- a/appl/ftp/ftp/ftp.c +++ b/appl/ftp/ftp/ftp.c @@ -567,6 +567,11 @@ copy_stream (FILE * from, FILE * to) #endif if (fstat (fileno (from), &st) == 0 && S_ISREG (st.st_mode)) { + /* + * mmap zero bytes has potential of loosing, don't do it. + */ + if (st.st_size == 0) + return 0; chunk = mmap (0, st.st_size, PROT_READ, MAP_SHARED, fileno (from), 0); if (chunk != (void *) MAP_FAILED) { int res;