mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2025-12-20 04:10: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 */
|
||||
{
|
||||
g_autofree gchar *path = g_strdup_printf ("/proc/%d/cgroup", pid);
|
||||
if (g_file_get_contents (path, &ret->cgroup, &length, &error))
|
||||
ret->cgroup [length - 1] = '\0'; /* Remove EOF character */
|
||||
else
|
||||
if (g_file_get_contents (path, &ret->cgroup, &length, &error)) {
|
||||
if (length > 0)
|
||||
ret->cgroup [length - 1] = '\0'; /* Remove EOF character */
|
||||
} else {
|
||||
wp_warning ("failed to get cgroup for PID %d: %s", pid, error->message);
|
||||
}
|
||||
}
|
||||
|
||||
/* Get args */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue