aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2018-08-01 02:11:58 +0300
committerMaxim Dounin <mdounin@mdounin.ru>2018-08-01 02:11:58 +0300
commit6bff9c9967dcac5fa03a0c1de6af0a1285c3d829 (patch)
treef6bd8bd8054a185962af5750df20ab35e983cb26
parentd5c43bf51c9c62d26c4c2c09a4a337d8b8b1c060 (diff)
downloadnginx-6bff9c9967dcac5fa03a0c1de6af0a1285c3d829.tar.gz
nginx-6bff9c9967dcac5fa03a0c1de6af0a1285c3d829.zip
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).
-rw-r--r--src/core/ngx_file.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c
index 3a94089de..57ad042de 100644
--- 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, 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,