From aa8037be325bcf13995676a9d8a199c96a61e540 Mon Sep 17 00:00:00 2001 From: jca Date: Wed, 8 Jan 2014 17:31:36 +0000 Subject: [PATCH] If the file size is zero, there's nothing to transmit so avoid spamming syslog with mmap failures. Noticed by and ok henning@, "looks right" deraadt@ --- libexec/ftpd/ftpd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index fc523178ee7..7bb51247f4c 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftpd.c,v 1.198 2013/08/22 04:43:40 guenther Exp $ */ +/* $OpenBSD: ftpd.c,v 1.199 2014/01/08 17:31:36 jca Exp $ */ /* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */ /* @@ -1586,6 +1586,12 @@ send_data(FILE *instr, FILE *outstr, off_t blksize, off_t filesize, int isreg) if (isreg && filesize < (off_t)16 * 1024 * 1024) { size_t fsize = (size_t)filesize; + if (fsize == 0) { + transflag = 0; + reply(226, "Transfer complete."); + return(0); + } + buf = mmap(0, fsize, PROT_READ, MAP_SHARED, filefd, (off_t)0); if (buf == MAP_FAILED) { -- 2.20.1