Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Commit 04197e0

Browse files
committed
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 <a.clayton@nginx.com>
1 parent 5dc0cf0 commit 04197e0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/rust/unit-wasm-sys/rusty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub fn uwr_get_http_content_str(ctx: *const luw_ctx_t) -> &'static str {
115115
unsafe {
116116
let slice = slice::from_raw_parts(
117117
uwr_get_http_content(ctx),
118-
uwr_get_http_content_len(ctx),
118+
uwr_get_http_total_content_sent(ctx),
119119
);
120120
str::from_utf8(slice).unwrap()
121121
}

0 commit comments

Comments
 (0)