bakaid commented on a change in pull request #610: MINIFICPP-814 - Fixed
ListenHTTP and HTTPClient bugs, created tests f…
URL: https://github.com/apache/nifi-minifi-cpp/pull/610#discussion_r302966922
##########
File path: extensions/http-curl/client/HTTPClient.cpp
##########
@@ -196,7 +255,7 @@ std::string HTTPClient::escape(std::string
string_to_escape) {
void HTTPClient::setPostFields(std::string input) {
curl_easy_setopt(http_session_, CURLOPT_POSTFIELDSIZE, input.length());
- curl_easy_setopt(http_session_, CURLOPT_POSTFIELDS, input.c_str());
+ curl_easy_setopt(http_session_, CURLOPT_COPYPOSTFIELDS, input.c_str());
Review comment:
CURLOPT_POSTFIELDS does NOT copy the data
(https://curl.haxx.se/libcurl/c/CURLOPT_POSTFIELDS.html), so using a temporary
std::string's c_str here is a use-after free which might be mitigated in some
cases by optimization, but has the potential to leak memory to remote servers.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services