mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00: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:
1 parent
d37c451e81
commit
8ce39f592c
1 file changed
+5
-2
@@ -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