If the file size is zero, there's nothing to transmit so avoid spamming
authorjca <jca@openbsd.org>
Wed, 8 Jan 2014 17:31:36 +0000 (17:31 +0000)
committerjca <jca@openbsd.org>
Wed, 8 Jan 2014 17:31:36 +0000 (17:31 +0000)
syslog with mmap failures.  Noticed by and ok henning@, "looks right"
deraadt@

libexec/ftpd/ftpd.c

index fc52317..7bb5124 100644 (file)
@@ -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) {