From 04197e036a01d3826e0529f1396924a868bb4dd2 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Tue, 29 Aug 2023 23:31:47 +0100 Subject: Rust/rusty: Make use of uwr_get_http_total_content_sent() When the uwr_get_http_content_str() function, which returns the request body content as a string, was added it used uwr_get_http_content_len() to determine the length of the returned string (the request body content is not null-terminated). This could potentially in some circumstances return too much data if the request was split over multiple calls into the Wasm module and uwr_get_http_content_str() was called before all the data had actually been received. Instead use the newly introduced uwr_get_http_total_content_sent() function to determine the amount of data to return in the string as it currently stands. Fixes: bf968c9 ("Rust/rusty: Add uwr_get_http_content_str()") Signed-off-by: Andrew Clayton --- src/rust/unit-wasm-sys/rusty.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rust/unit-wasm-sys/rusty.rs b/src/rust/unit-wasm-sys/rusty.rs index 81b3e5b..3ef7e82 100644 --- a/src/rust/unit-wasm-sys/rusty.rs +++ b/src/rust/unit-wasm-sys/rusty.rs @@ -115,7 +115,7 @@ pub fn uwr_get_http_content_str(ctx: *const luw_ctx_t) -> &'static str { unsafe { let slice = slice::from_raw_parts( uwr_get_http_content(ctx), - uwr_get_http_content_len(ctx), + uwr_get_http_total_content_sent(ctx), ); str::from_utf8(slice).unwrap() } -- cgit