Skip to content

fix: prevent direct construction of BorrowedHeaders#835

Open
Sieger9303 wants to merge 1 commit into
fede1024:masterfrom
Sieger9303:fix-borrowed-headers-construction
Open

fix: prevent direct construction of BorrowedHeaders#835
Sieger9303 wants to merge 1 commit into
fede1024:masterfrom
Sieger9303:fix-borrowed-headers-construction

Conversation

@Sieger9303
Copy link
Copy Markdown

Fixes #825.

Hi, thanks for maintaining this crate.

BorrowedHeaders represents a borrowed view over a native rd_kafka_headers_t pointer. Its methods convert &BorrowedHeaders back into that native pointer before calling librdkafka.

Because BorrowedHeaders was a public unit struct, downstream safe code could construct one directly. Such a value is not backed by a valid librdkafka headers pointer, so calling methods like detach() could pass an invalid pointer to librdkafka and segfault.

This PR adds a private field to BorrowedHeaders, making it non-constructible outside the crate while keeping the normal construction paths through borrowed messages and owned headers unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Potential soundness issue: BorrowedHeaders appears constructible in safe Rust; detach() may segfault under ASan

1 participant