centos 7
buffer weakness #7

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:

v4l-utils-0.9.5/lib/libdvbv5/descriptors.c

Context:

The highlighted line of code below is the trigger point of this particular Centos 7 buffer weakness.

 		int dlen = buf[1];

		if (buf[0] == needed_descriptor)
			return 1;

		buf += dlen + 2;
		len -= dlen + 2;
	} while (len > 0);

	return 0;
}

void hexdump(struct dvb_v5_fe_parms *parms, const char *prefix, const unsigned char *data, int length)
{
	if (!data)
		return;
	char ascii[17];
	char hex[50];
	int i, j = 0;
	hex[0] = '\0';
	for (i = 0; i < length; i++)
	{
		char t[4];
		snprintf (t, sizeof(t), "%02x ", (unsigned int) data[i]);
		strncat (hex, t, sizeof(hex));
		if (data[i] > 31 && data[i] < 128 )
			ascii[j] = data[i];
		else
			ascii[j] = '.';
		j++;
		if (j == 8)
			strncat(hex, " ", sizeof(hex));
		if (j == 16)
		{
			ascii[j] = '\0';
			dvb_log("%s%s  %s", prefix, hex, ascii);
			j = 0;
			hex[0] = '\0';
		}
	}
	if (j > 0 && j < 16)
	{
		char spaces[47];
		spaces[0] = '\0';
		for (i = strlen(hex); i < 49; i++)
			strncat(spaces, " ", sizeof(spaces));
		ascii[j] = '\0';
		dvb_log("%s%s %s %s", prefix, hex, spaces, ascii);
	}
 

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.