# HG changeset patch # User Maxim Dounin # Date 1533078718 -10800 # Node ID 3c357206a3b8777ed6fca3d9ce5971cd3a35c5c1 # Parent f7e79596baf209151682f2f7d220161c034657ac Dav: fixed ngx_copy_file() to truncate destination file. Previously, ngx_open_file(NGX_FILE_CREATE_OR_OPEN) was used, resulting in destination file being partially rewritten if exists. Notably, this affected WebDAV COPY command (ticket #1576). diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c --- a/src/core/ngx_file.c +++ b/src/core/ngx_file.c @@ -839,8 +839,7 @@ ngx_copy_file(u_char *from, u_char *to, goto failed; } - nfd = ngx_open_file(to, NGX_FILE_WRONLY, NGX_FILE_CREATE_OR_OPEN, - cf->access); + nfd = ngx_open_file(to, NGX_FILE_WRONLY, NGX_FILE_TRUNCATE, cf->access); if (nfd == NGX_INVALID_FILE) { ngx_log_error(NGX_LOG_CRIT, cf->log, ngx_errno,