diff options
author | Kim Alvefur <zash@zash.se> | 2021-01-27 00:09:49 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-01-27 00:09:49 +0100 |
commit | 987976f20f4428af0981d69c3afda0047f4bea5e (patch) | |
tree | 14857ae0bc5bd04eaa24a47d070825ca2dbe2964 | |
parent | 456ca909e253ce26bf435619a91a3e1fa40f87dd (diff) | |
download | prosody-987976f20f4428af0981d69c3afda0047f4bea5e.tar.gz prosody-987976f20f4428af0981d69c3afda0047f4bea5e.zip |
mod_http_file_share: Verify final file size on completion of upload
-rw-r--r-- | plugins/mod_http_file_share.lua | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/plugins/mod_http_file_share.lua b/plugins/mod_http_file_share.lua index a4ac4693..ef427b94 100644 --- a/plugins/mod_http_file_share.lua +++ b/plugins/mod_http_file_share.lua @@ -173,7 +173,12 @@ function handle_upload(event, path) -- PUT /upload/:slot end if request.body_sink then + local final_size = request.body_sink:seek(); local uploaded, err = errors.coerce(request.body_sink:close()); + if final_size ~= upload_info.filesize then + -- Could be too short as well, but we say the same thing + uploaded, err = false, 413; + end if uploaded then assert(os.rename(filename.."~", filename)); return 201; |