mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
procname_kill(): Fix possible resource leak and let's use opendir() errno
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -270,12 +270,15 @@ int procname_kill(char *name, int signo)
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
|
||||
dir = opendir("/proc");
|
||||
if (!dir || !name) {
|
||||
if (!name) {
|
||||
errno = EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
dir = opendir("/proc");
|
||||
if (!dir)
|
||||
return 0;
|
||||
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
/* Skip non-process entries in /proc */
|
||||
if (!isdigit(*entry->d_name))
|
||||
|
||||
Reference in New Issue
Block a user