aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_http_file_share.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-01-27 00:36:49 +0100
committerKim Alvefur <zash@zash.se>2021-01-27 00:36:49 +0100
commit3ab51f686468eac1693b611d0526b20fed6bcd6e (patch)
tree2ed9d3767f5bcaa68f4e6be3a047e637c9fd85ca /plugins/mod_http_file_share.lua
parentdebea1badc4630e49303e71848bda7cd28559c74 (diff)
downloadprosody-3ab51f686468eac1693b611d0526b20fed6bcd6e.tar.gz
prosody-3ab51f686468eac1693b611d0526b20fed6bcd6e.zip
mod_http_file_share: Reject invalid file sizes
Diffstat (limited to 'plugins/mod_http_file_share.lua')
-rw-r--r--plugins/mod_http_file_share.lua4
1 files changed, 4 insertions, 0 deletions
diff --git a/plugins/mod_http_file_share.lua b/plugins/mod_http_file_share.lua
index 8a47b824..8d3310c9 100644
--- a/plugins/mod_http_file_share.lua
+++ b/plugins/mod_http_file_share.lua
@@ -48,6 +48,7 @@ local upload_errors = errors.init(module.name, namespace, {
filetype = { type = "modify"; condition = "not-acceptable"; text = "File type not allowed" };
filesize = { type = "modify"; condition = "not-acceptable"; text = "File too large";
extra = {tag = st.stanza("file-too-large", {xmlns = namespace}):tag("max-file-size"):text(tostring(file_size_limit)) };
+ filesizefmt = { type = "modify"; condition = "bad-request"; text = "File size must be positive integer"; }
};
});
@@ -62,6 +63,9 @@ function may_upload(uploader, filename, filesize, filetype) -- > boolean, error
return false, upload_errors.new("filename");
end
+ if not filesize or filesize < 0 or filesize % 1 ~= 0 then
+ return false, upload_errors.new("filesizefmt");
+ end
if filesize > file_size_limit then
return false, upload_errors.new("filesize");
end