mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2025-12-20 15:50:03 +01:00
proc-utils: Make sure cgroup length is valid before removing EOF char
This fixes a Coverity Scan defect.
This commit is contained in:
parent
0f3e005a92
commit
ce4f9b08a9
1 changed files with 5 additions and 3 deletions
|
|
@ -179,10 +179,12 @@ wp_proc_utils_get_proc_info (pid_t pid)
|
||||||
/* Get cgroup */
|
/* Get cgroup */
|
||||||
{
|
{
|
||||||
g_autofree gchar *path = g_strdup_printf ("/proc/%d/cgroup", pid);
|
g_autofree gchar *path = g_strdup_printf ("/proc/%d/cgroup", pid);
|
||||||
if (g_file_get_contents (path, &ret->cgroup, &length, &error))
|
if (g_file_get_contents (path, &ret->cgroup, &length, &error)) {
|
||||||
ret->cgroup [length - 1] = '\0'; /* Remove EOF character */
|
if (length > 0)
|
||||||
else
|
ret->cgroup [length - 1] = '\0'; /* Remove EOF character */
|
||||||
|
} else {
|
||||||
wp_warning ("failed to get cgroup for PID %d: %s", pid, error->message);
|
wp_warning ("failed to get cgroup for PID %d: %s", pid, error->message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get args */
|
/* Get args */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue