From e042f447bd327e0cd7e9aba7691752e770c33152 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 8 Apr 2025 16:14:31 +0200 Subject: [PATCH] rest-serve: move max body size limit to a constant Signed-off-by: Thomas Lamprecht --- proxmox-rest-server/src/rest.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/proxmox-rest-server/src/rest.rs b/proxmox-rest-server/src/rest.rs index 98e8268f..4a3580e9 100644 --- a/proxmox-rest-server/src/rest.rs +++ b/proxmox-rest-server/src/rest.rs @@ -65,6 +65,8 @@ pub struct RestServer { } const MAX_URI_QUERY_LENGTH: usize = 3072; +const MAX_REQUEST_BODY_SIZE: usize = 512 * 1024; + const CHUNK_SIZE_LIMIT: u64 = 32 * 1024; impl RestServer { @@ -405,7 +407,7 @@ async fn get_request_parameters( http_err!(BAD_REQUEST, "Problems reading request body: {}", err) }) .try_fold(Vec::new(), |mut acc, chunk| async move { - if acc.len() + chunk.len() < 512 * 1024 { + if acc.len() + chunk.len() < MAX_REQUEST_BODY_SIZE { acc.extend_from_slice(&chunk); Ok(acc) } else {