alpine 3.9
format weakness #22

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

Context:

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

 	// seconds" format described at http://www.w3.org/TR/NOTE-datetime, i.e.
	// YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00), but without TZD.
	// WordPerfect does not use the timeZone field, so we don't know the offset
	librevenge::RVNGString dateStr;      // filled in and passed to m_metaData.insert()

	m_tm.tm_sec       = second;
	m_tm.tm_min       = minute;
	m_tm.tm_hour      = hour;
	m_tm.tm_mday      = day;
	m_tm.tm_mon       = month - TMMONTHOFFSET;
	m_tm.tm_year      = year - TMYEAROFFSET;
	m_tm.tm_wday      = (dayOfWeek + WPMONDAYOFFSET) % DAYSINWEEK;
	m_tm.tm_yday      = 0;
	m_tm.tm_isdst     = -1;

	retVal = strftime(dateBuffer, DATEBUFLEN, dateFormat, &m_tm);
	if (retVal <= 0)
	{
		// error - date wouldn't fit in buffer
		dateStr.sprintf("ERROR: %d character buffer too short for date", DATEBUFLEN);
		return; // don't continue, because we cannot trust the data here
	}
	else
	{
		dateStr.sprintf("%s", dateBuffer);
	}

	switch (type)
	{
	case (WP6_INDEX_HEADER_EXTENDED_DOCUMENT_SUMMARY_CREATION_DATE):
		m_metaData.insert("meta:creation-date", dateStr);
		break;
	case (WP6_INDEX_HEADER_EXTENDED_DOCUMENT_SUMMARY_DATE_COMPLETED):
		m_metaData.insert("dcterms:available", dateStr);
		break;
	case (WP6_INDEX_HEADER_EXTENDED_DOCUMENT_SUMMARY_RECORDED_DATE):
		m_metaData.insert("librevenge:recorded-date", dateStr);
		break;
	// NOTE: Revision Date is not set in WP Document Summary
	// and sometimes contains non-zero data, so it's confusing.
	// WordPerfect actually uses the file modification time
	// to display Revision Date in Properties.
	//case (WP6_INDEX_HEADER_EXTENDED_DOCUMENT_SUMMARY_REVISION_DATE):
	//	m_metaData.insert("librevenge:revision-date", dateStr);
	//	break;
	case (WP6_INDEX_HEADER_EXTENDED_DOCUMENT_SUMMARY_VERSION_DATE):
		m_metaData.insert("dcterms:issued", dateStr);
		break;
	default:
		break; 

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.