http client crashes when sending large chunk data via PUT method

Bug #1570686 reported by Gary.Wang
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Canonical System Image
Fix Committed
High
Unassigned
net-cpp
In Progress
High
Gary.Wang

Bug Description

When sending large chuck of data via PUT method, http client crashes.
The requested buffer size doesn't match the one internal buffer(accumulating data) allocated.

Test case as following:

TEST(HttpClient, put_request_for_file_with_large_chunk_succeeds)
  {
      auto client = http::make_client();
      auto url = std::string(httpbin::host) + httpbin::resources::put();

      // create temp file with large chunk
      const std::size_t size = 1024*1024;
      std::ofstream ofs("tmp.dat", std::ios::binary | std::ios::out);
      ofs.seekp(size);
      ofs.write("", 1);
      ofs.close();

      std::ifstream payload("tmp.dat");
      auto request = client->put(http::Request::Configuration::from_uri_as_string(url),
                                 payload,
                                 size);

      json::Value root;
      json::Reader reader;

      auto response = request->execute(default_progress_reporter);

      EXPECT_EQ(core::net::http::Status::ok, response.status);
      EXPECT_TRUE(reader.parse(response.body, root));
      EXPECT_EQ(url, root["url"].asString());
  }

......
[----------] 1 test from HttpClient
[ RUN ] HttpClient.put_request_for_file_with_large_chunk_succeeds
Segmentation fault (core dumped)

Related branches

Gary.Wang (gary-wzl77)
Changed in net-cpp:
assignee: nobody → Gary.Wang (gary-wzl77)
Gary.Wang (gary-wzl77)
Changed in net-cpp:
status: New → In Progress
Changed in net-cpp:
importance: Undecided → High
Changed in canonical-devices-system-image:
milestone: none → 14
importance: Undecided → High
status: New → Confirmed
status: Confirmed → In Progress
Changed in canonical-devices-system-image:
status: In Progress → Fix Committed
Changed in canonical-devices-system-image:
milestone: 14 → backlog
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.