Skip to content

Implementation of the error buffer in Easy2 is unsound #589

Open
@kadiwa4

Description

@kadiwa4

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions