# HG changeset patch # User Kim Alvefur # Date 1611702589 -3600 # Node ID ae0461b37fbebf289c80e10d8dea525207b3a5d2 # Parent c52fcea39c8ed70b5a136df80deaac29f3d942a7 mod_http_file_share: Verify final file size on completion of upload diff -r c52fcea39c8e -r ae0461b37fbe plugins/mod_http_file_share.lua --- a/plugins/mod_http_file_share.lua Tue Jan 26 14:53:43 2021 +0100 +++ b/plugins/mod_http_file_share.lua Wed Jan 27 00:09:49 2021 +0100 @@ -173,7 +173,12 @@ 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;