alpine 3.9
format weakness #21


Weakness Breakdown


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:



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

	for (auto &image : m_images)
		if (image)
			delete image;
		image = 0;

void WP5GraphicsInformationPacket::_readContents(librevenge::RVNGInputStream *input, WPXEncryption *encryption, unsigned /* dataSize */)
	unsigned short tmpImagesCount = readU16(input, encryption);
	std::vector<unsigned> tmpImagesSizes;
	for (unsigned short i = 0; i < tmpImagesCount; i++)
		tmpImagesSizes.push_back(readU32(input, encryption));

	for (unsigned short j = 0; j < tmpImagesCount; j++)
		unsigned char *tmpData = new unsigned char[tmpImagesSizes[j]];

		for (unsigned k = 0; k < tmpImagesSizes[j]; k++)
			tmpData[k] = readU8(input, encryption);
#if 0
		librevenge::RVNGString filename;
		filename.sprintf("binarydump%.4x.wpg", j);
		FILE *f = fopen(filename.cstr(), "wb");
		if (f)
			if (tmpData[0]!=0xff || tmpData[1]!='W'  || tmpData[2]!='P'  || tmpData[3]!='C')
				// Here we create a file header, since it looks like some embedded files do not contain it
				fprintf(f, "%c%c%c%c", 0xff, 0x57, 0x50, 0x43);
				fprintf(f, "%c%c%c%c", 0x10, 0x00, 0x00, 0x00);
				fprintf(f, "%c%c%c%c", 0x01, 0x16, 0x01, 0x00);
				fprintf(f, "%c%c%c%c", 0x00, 0x00, 0x00, 0x00);

			for (unsigned l = 0; l < tmpImagesSizes[j]; l++)
				fprintf(f, "%c", tmpData[l]);
		m_images.push_back(new librevenge::RVNGBinaryData(tmpData, tmpImagesSizes[j]));
/* 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.