alpine 3.9
format weakness #29

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):

If format strings can be influenced by an attacker, they can be exploited.

File Name:

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

Context:

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

  */

/* "This product is not manufactured, approved, or supported by
 * Corel Corporation or Corel Corporation Limited."
 */
#include "libwpd_internal.h"
#include <librevenge-stream/librevenge-stream.h>
#include <cstdarg>
#include <cstdio>
#include <ctype.h>
#include <locale.h>
#include <string>
#include <vector>

#include <boost/spirit/include/qi.hpp>

#ifdef DEBUG
namespace libwpd
{

void debugPrint(const char *format, ...)
{
	va_list args;
	va_start(args, format);
	std::vfprintf(stderr, format, args);
	va_end(args);
}

}
#endif

namespace
{

static int libwpd_unichar_to_utf8(unsigned c, char *outbuf)
{
	unsigned char len = 1;
	unsigned char first = 0;

	if (c < 0x80)
	{
		first = 0;
		len = 1;
	}
	else if (c < 0x800)
	{
		first = 0xc0;
		len = 2;
	}
	else if (c < 0x10000) 

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.