]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Add Locker friend class to SBuf for protection against memory issues
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 30 Oct 2015 12:59:17 +0000 (05:59 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 30 Oct 2015 12:59:17 +0000 (05:59 -0700)
When appending or otherwise modifying an SBuf based on a SBuf& or char*
the parameter used may be pointing at the MemBlob memory buffer
indirectly without holding a separate ref-count lock to it.

If 'this' SBuf then requires reallocation for any reason the char* or
buffer pointer taken from the SBuf&, which is being manipulated may in
fact be left pointing at invalid memory.

Utilize a private Locker class to create relatively cheap ref-count locks
on the store_ MemBlob when this problem MAY occur. This Locker needs to
be used on all non-const SBuf methods accepting char* or SBuf& argument.


Trivial merge