Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of the error buffer in Easy2 is unsound #589

Open
kadiwa4 opened this issue Nov 22, 2024 · 0 comments
Open

Implementation of the error buffer in Easy2 is unsound #589

kadiwa4 opened this issue Nov 22, 2024 · 0 comments

Comments

@kadiwa4
Copy link

kadiwa4 commented Nov 22, 2024

curl::easy::Easy2::default_configure registers an error buffer like this:

self.setopt_ptr(
    curl_sys::CURLOPT_ERRORBUFFER,
    self.inner.error_buf.borrow().as_ptr() as *const _,
)
.expect("failed to set error buffer");

CURLOPT_ERRORBUFFER requires mutable access over the buffer, and it is important that the buffer pointer is still valid later on when further library calls are made. However, error_buf is borrowed immutably and only for a short time (until the end of the statement).

(A mutable borrow might look like this:

self.inner.error_buf.borrow_mut().as_mut_ptr() as *const u8 as *const _

That does not solve the lifetime problem, though.)

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

No branches or pull requests

1 participant