Skip to content

Commit

Permalink
Dav: fixed ngx_copy_file() to truncate destination file.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
mdounin committed Jul 31, 2018
1 parent d5c43bf commit 6bff9c9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/core/ngx_file.c
Expand Up @@ -839,8 +839,7 @@ ngx_copy_file(u_char *from, u_char *to, ngx_copy_file_t *cf)
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,
Expand Down

0 comments on commit 6bff9c9

Please sign in to comment.