alpine 3.9
format weakness #20

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/WP5FootnoteEndnoteGroup.cpp

Context:

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

 void WP5FootnoteEndnoteGroup::_readContents(librevenge::RVNGInputStream *input, WPXEncryption *encryption)
{
	int tmpSizeOfNote = getSize() - 8;
	unsigned char tmpFlags = readU8(input, encryption);
	tmpSizeOfNote -= 1;
	int tmpNumOfNote = readU16(input, encryption);
	tmpSizeOfNote -= 2;
	if (getSubGroup() == WP5_FOOTNOTE_ENDNOTE_GROUP_FOOTNOTE)
	{
		int tmpNumOfAdditionalPages = readU8(input, encryption);
		tmpSizeOfNote -= 1;
		input->seek(2*(tmpNumOfAdditionalPages+1) + 9, librevenge::RVNG_SEEK_CUR);
		tmpSizeOfNote -= 2*(tmpNumOfAdditionalPages+1) + 9;
	}
	else /* WP5_FOOTNOTE_ENDNOTE_GROUP_ENDNOTE */
	{
		input->seek(4, librevenge::RVNG_SEEK_CUR);
		tmpSizeOfNote -= 4;
	}

	m_subDocument = new WP5SubDocument(input, encryption, (unsigned)tmpSizeOfNote);
	if (tmpFlags & 0x80)
		m_noteReference.sprintf("%c", tmpNumOfNote);
	else
		m_noteReference.sprintf("%i", tmpNumOfNote);
}

void WP5FootnoteEndnoteGroup::parse(WP5Listener *listener)
{
	WPD_DEBUG_MSG(("WordPerfect: handling a Footnote/Endnote group\n"));
	listener->insertNoteReference(m_noteReference);
	switch (getSubGroup())
	{
	case WP5_FOOTNOTE_ENDNOTE_GROUP_FOOTNOTE:
		listener->insertNote(FOOTNOTE, m_subDocument);
		break;
	case WP5_FOOTNOTE_ENDNOTE_GROUP_ENDNOTE:
		listener->insertNote(ENDNOTE, m_subDocument);
		break;
	default: // something else we don't support, since it isn't in the docs
		break;
	}
}
/* 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.