mirror of
https://github.com/troglobit/finit.git
synced 2026-11-14 19:03:16 +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;
|
DIR *dir;
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
|
|
||||||
dir = opendir("/proc");
|
if (!name) {
|
||||||
if (!dir || !name) {
|
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dir = opendir("/proc");
|
||||||
|
if (!dir)
|
||||||
|
return 0;
|
||||||
|
|
||||||
while ((entry = readdir(dir)) != NULL) {
|
while ((entry = readdir(dir)) != NULL) {
|
||||||
/* Skip non-process entries in /proc */
|
/* Skip non-process entries in /proc */
|
||||||
if (!isdigit(*entry->d_name))
|
if (!isdigit(*entry->d_name))
|
||||||
|
|||||||
Reference in new issue
Block a user