alpine 3.9
format weakness #23

4

Weakness Breakdown


Definition:

A format string exploit occurs when the data of an input string is evaluated as a command by the program. This class of attacks is very similar to buffer overflows since an attacker could execute code, read the stack or cause new behaviors that compromise security. Learn more about format string attacks on OWASP attack index.

Warning code(s):

Potential format string problem.

File Name:

libwpd/src/libwpd-0.10.2/src/lib/WP6GraphicsCachedFileDataPacket.cpp

Context:

The highlighted line of code below is the trigger point of this particular Alpine 3.9 format weakness.

 	m_object(nullptr),
	m_data(nullptr)
{
	_read(input, encryption, dataOffset, dataSize);
}

WP6GraphicsCachedFileDataPacket::~WP6GraphicsCachedFileDataPacket()
{
	if (m_data)
		delete [] m_data;
	m_data = nullptr;
	if (m_object)
		delete m_object;
	m_object = nullptr;
}

void WP6GraphicsCachedFileDataPacket::_readContents(librevenge::RVNGInputStream *input, WPXEncryption *encryption)
{
	unsigned tmpDataSize = getDataSize();
	m_data = new unsigned char[tmpDataSize];
	for (unsigned i = 0; i < tmpDataSize; i++)
		m_data[i] = readU8(input, encryption);
#if 0
	librevenge::RVNGString filename;
	filename.sprintf("binarydump%.4x.wpg", m_id);
	FILE *f = fopen(filename.cstr(), "wb");
	if (f) // don't crash when current directory is on read-only file-system
	{
		for (unsigned j = 0; j < tmpDataSize; j++)
			fprintf(f, "%c", m_data[j]);
		fclose(f);
	}
#endif
	m_object = new librevenge::RVNGBinaryData(m_data, tmpDataSize);
}
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.