From 019efb0ed8ebaee8d23301d921e2c79ff293bab2 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Sun, 8 Sep 2019 02:15:15 -0400 Subject: [PATCH] [mod_webdav] fix file uploads > 128M (fixes #2970) (thx Gundersanne) x-ref: "mod_webdav writes to fd=-1 when uploading large files (1000M)" https://redmine.lighttpd.net/issues/2970 --- src/mod_webdav.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mod_webdav.c b/src/mod_webdav.c index 16f74170..1f690722 100644 --- a/src/mod_webdav.c +++ b/src/mod_webdav.c @@ -3325,7 +3325,7 @@ webdav_mmap_file_chunk (chunk * const c) /*(request body provided in temporary file, so ok to mmap(). * Otherwise, must check defined(ENABLE_MMAP)) */ /* chunk_reset() or chunk_free() will clean up mmap'd chunk */ - /* close c->file.fd only faster mmap() succeeds, since it will not + /* close c->file.fd only after mmap() succeeds, since it will not * be able to be re-opened if it was a tmpfile that was unlinked */ /*assert(c->type == FILE_CHUNK);*/ if (MAP_FAILED != c->file.mmap.start) @@ -4274,6 +4274,9 @@ mod_webdav_put_prep (connection * const con, const plugin_config * const pconf) } buffer_clear(cq->last->mem); /* file already unlink()ed */ chunkqueue_set_tempdirs(cq, cq->tempdirs, INTMAX_MAX); + /* force huge cq->upload_temp_file_size since chunkqueue_set_tempdirs() + * might truncate upload_temp_file_size to chunk.c:MAX_TEMPFILE_SIZE */ + cq->upload_temp_file_size = INTMAX_MAX; cq->last->file.is_temp = 1; return HANDLER_GO_ON;