fedora 23
buffer weakness #38

5

Weakness Breakdown


Definition:

Buffer overflows are one of the most well-known software vulnerabilities. Even though most developers know what buffer overflows are, attacks against the vulnerabilities are common in both legacy and newer applications. A classic buffer overflow exploit begins with the attacker sending data to a program, which it then stores in an undersized stack buffer. Besides stack buffer overflows, other kinds of buffer overflows include heap overflows, off-by-one errors and many others. Learn more about buffer overflows on OWASP attack index.

Warning code(s):

Easily used incorrectly.

File Name:

dump-0.4b46/restore/xattr.c

Context:

The highlighted line of code below is the trigger point of this particular Fedora 23 buffer weakness.

 
	return GOOD;
}

static int
xattr_cb_compare(char *name, char *value, int valuelen, int isSELinux, void *private)
{
	char *path = (char *)private;
	char valuef[XATTR_MAXSIZE];
	int valuesz;

	isSELinux;
#ifdef TRANSSELINUX			/*GAN6May06 SELinux MLS */
	if (isSELinux)
	{
		security_context_t con = NULL;

		if (lgetfilecon(path, &con) < 0) {
			warn("%s: EA compare lgetfilecon failed\n", path);
			return FAIL;
		}

		valuesz = strlen(con) + 1;
		valuef[0] = 0;
		strncat(valuef, con, sizeof(valuef) - 1);
		freecon(con);
	}
	else {
#endif
		valuesz = lgetxattr(path, name, valuef, XATTR_MAXSIZE);
		if (valuesz < 0) {
			warn("%s: EA compare lgetxattr failed\n", path);
			return FAIL;
		}
#ifdef TRANSSELINUX			/*GAN6May06 SELinux MLS */
	}
#endif

	if (valuesz != valuelen || memcmp(value, valuef, valuelen)) {
		/* GAN24May06: show name and new value for user to compare */
		fprintf(stderr, "%s: EA %s:%s value changed to %s\n", path, name, value, valuef);
		return FAIL;
	}

	return GOOD;
}

static int
xattr_verify(char *buffer)
{ 

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.