rhel 6
buffer weakness #55

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:

libcgroup-0.40.rc1/src/tools/lssubsys.c

Context:

The highlighted line of code below is the trigger point of this particular Red Hat Enterprise Linux 6 buffer weakness.

 	(void) cgroup_init();

	ret = cgroup_get_all_controller_begin(&handle, &info);
	if ((ret != 0) && (ret != ECGEOF)) {
		fprintf(stderr, "cannot read controller data: %s\n",
			cgroup_strerror(ret));
		return ret;
	}

	while (ret != ECGEOF) {
		/* controller is in the hierrachy */
		if (info.hierarchy != hierarchy)
			goto next;

		if (first) {
			/* the first controller in the hierarchy */
			memset(cont_name, 0, FILENAME_MAX);
			strncpy(cont_name, info.name, FILENAME_MAX-1);
			memset(cont_names, 0, FILENAME_MAX);
			strncpy(cont_names, info.name, FILENAME_MAX-1);
			first = 0;
		} else {
			/* the next controller in the hierarchy */
			strncat(cont_names, ",", FILENAME_MAX-1);
			strncat(cont_names, info.name, FILENAME_MAX-1);
		}
next:
		ret = cgroup_get_all_controller_next(&handle, &info);
		if (ret && ret != ECGEOF)
			goto end;
	}

	ret = print_controller_mount(cont_name,
		flags, cont_names, hierarchy);

end:
	cgroup_get_all_controller_end(&handle);

	if (ret == ECGEOF)
		ret = 0;

	return ret;
}


/* go through the list of all controllers gather them based on hierarchy number
 and print them */
static int cgroup_list_all_controllers(const char *tname,
	cont_name_t cont_name[CG_CONTROLLER_MAX], int c_number, int flags)
{ 

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.