Mitigate Baron SameEdit (CVE-2021-3156) vulnerability

fedora 25
format weakness #17

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:

magicpoint-1.13a/draw.c

Context:

The highlighted line of code below is the trigger point of this particular Fedora 25 format weakness.

 		registry = "iso8859-1";

	if (siz < 0)
		strcpy(tmp2, "*");
	else
		sprintf(tmp2, "%d", siz);

	hyphen = 0;
	for (p = seed; *p; p++) {
		if (*p == '-')
			hyphen++;
	}
	switch (hyphen) {
	case 0:
		/* for "a14", "5x8", or such an short names */
		if ((fontlist = XListFonts(display, seed, 1, &count))) {
			XFreeFontNames(fontlist);
			strcpy(buf, seed);
			break;
		}
		sprintf(tmp, "%s-*-*", seed);
		sprintf(buf, FONT_FORMAT, tmp, tmp2, registry);
		break;
	case 2:
		sprintf(buf, FONT_FORMAT, seed, tmp2, registry);
		break;
	case XLFD_HYPHEN:
		/* as is */
		strcpy(buf, seed);
		break;
	case 1:	/* should not happen */
		fprintf(stderr, "internal error: invalid seed <%s>\n", seed);
		exit(1);
	}
	if (mgp_flag & FL_VERBOSE) {
		fprintf(stderr, "fontname: seed=<%s> siz=<%d> reg=<%s> "
			"result=<%s>\n",
			seed, siz, registry, buf);
	}
	return buf;
}

static int
x_parsefont(xfont, pixel, truescalable)
	char *xfont;
	int *pixel;
	int *truescalable;
{
	char *p;
	int fsize; 

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.