aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_http_file_share.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-01-27 00:09:49 +0100
committerKim Alvefur <zash@zash.se>2021-01-27 00:09:49 +0100
commit19be6e8a27757d534fc9344496814dd08a72ffd1 (patch)
tree14857ae0bc5bd04eaa24a47d070825ca2dbe2964 /plugins/mod_http_file_share.lua
parentafa3ec821af60d73dd2ee4da19d4baff34baab9a (diff)
downloadprosody-19be6e8a27757d534fc9344496814dd08a72ffd1.tar.gz
prosody-19be6e8a27757d534fc9344496814dd08a72ffd1.zip
mod_http_file_share: Verify final file size on completion of upload
Diffstat (limited to 'plugins/mod_http_file_share.lua')
-rw-r--r--plugins/mod_http_file_share.lua5
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;