Skip to content

Buffer::resize crash #41

@CyberCMRX

Description

@CyberCMRX

In poco Version 1.5.0 up the resize code isn't correct:

if (newCapacity > _capacity)
{
T* ptr = new T[newCapacity];
if (preserveContent)
std::memcpy(ptr, _ptr, newCapacity); <<<<<< since newCapacity is bigger than the allocated memory it tries to access memory outside the allowed boundaries.

Calling NetworkInterface::map several times it will crash from time to time.
if (ERROR_BUFFER_OVERFLOW == (dwRetVal = GetAdaptersAddresses(family, flags, 0, pAddress, &outBufLen)))
memory.resize(outBufLen); // adjust size and try again

Don't know why not calling memory.resize(outBufLen, false); there.
Is preserving the memory necessary?

In poco 1.4.4 the resize is fine!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions