In cgroup_init(), the first line/header of /proc/cgroups helps in
interpreting the values in the remaining of the file. We are interested
in the rest of the file and a temporary buffer of size FILENAME_MAX is
allocated/deallocated after reading the header. The length of the header
is only 56 characters in length, excluding the newline. This patch
reduces it to LL_MAX a.k.a 100 characters.
LL_MAX is used instead of introducing another new length macro.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
/*
* The first line of the file has stuff we are not interested in.
* So just read it and discard the information.
- *
- * XX: fix the size for fgets
*/
- buf = malloc(FILENAME_MAX);
+ buf = malloc(LL_MAX);
if (!buf) {
last_errno = errno;
ret = ECGOTHER;
goto unlock_exit;
}
- if (!fgets(buf, FILENAME_MAX, proc_cgroup)) {
+ if (!fgets(buf, LL_MAX, proc_cgroup)) {
free(buf);
cgroup_err("Error: cannot read /proc/cgroups: %s\n",
strerror(errno));