Skip to content

Memory corruption in http::client::post #482

@urbanyoung

Description

@urbanyoung

I'm using the latest stable release (0.11.1-final) downloaded from http://cpp-netlib.org/ and have noticed that references to a local object are being stored for certain post requests. I apologize in advance for the poor quality of this report, but the code I downloaded from your website doesn't seem to match the repo. For instance, in the downloaded code the problem file is boost/network/protocol/http/client/facade.hpp and the closest I can find in the repo is https://github.com/cpp-netlib/cpp-netlib/blob/master/http/src/network/protocol/http/client/facade.ipp#L46

Regardless, they both have the same issue.

The linked function operates on a local copy of the request object which then gets passed, by reference, to request_skeleton. Eventually host() is called on this object, and the result is stored. Later on, when the newly created thread tries to access the stored data, it is no longer valid because the local request object has long since been destroyed.

I don't have a proposed fixed because I'm not familiar enough with the library, but in my own code I simply changed post to accept a reference, and ensure the request remains valid for the duration of the post.

Hope that makes sense.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions