~kinkie/squid/testbranch

« back to all changes in this revision

Viewing changes to src/client_side_request.cc

  • Committer: Alex Rousskov
  • Date: 2016-10-06 22:05:50 UTC
  • Revision ID: rousskov@measurement-factory.com-20161006220550-hne7crvcbbbf05bs
Fix known "concurrent c_str()s" violations of SBuf API.

The second c_str() call destroys the buffer still being used by the
first c_str() result, leading to many "Invalid read of size N" errors.

IMO, we must instead fix SBuf to make similar violations unlikely, but
there is currently no squid-dev consensus on whether and how to do that.
See "[RFC] Support concurrent SBuf::c_str() calls" thread on squid-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1787
1787
 
1788
1788
    if (calloutContext->error) {
1789
1789
        // XXX: prformance regression. c_str() reallocates
1790
 
        SBuf storeUri(request->storeId());
1791
 
        StoreEntry *e = storeCreateEntry(storeUri.c_str(), storeUri.c_str(), request->flags, request->method);
 
1790
        SBuf storeUriBuf(request->storeId());
 
1791
        const char *storeUri = storeUriBuf.c_str();
 
1792
        StoreEntry *e = storeCreateEntry(storeUri, storeUri, request->flags, request->method);
1792
1793
#if USE_OPENSSL
1793
1794
        if (sslBumpNeeded()) {
1794
1795
            // We have to serve an error, so bump the client first.