projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
6ff769e
)
check fscanf return value in process_check
author
Andrew Bays
<abays@redhat.com>
Wed, 13 Dec 2017 17:50:13 +0000
(12:50 -0500)
committer
Andrew Bays
<andrew.bays@gmail.com>
Wed, 4 Sep 2019 19:50:14 +0000
(15:50 -0400)
src/procevent.c
patch
|
blob
|
history
diff --git
a/src/procevent.c
b/src/procevent.c
index
e4f473b
..
e05fa0c
100644
(file)
--- a/
src/procevent.c
+++ b/
src/procevent.c
@@
-103,7
+103,7
@@
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
// Does /proc/<pid>/comm contain a process name we are interested in?
static processlist_t *process_check(int pid) {
// Does /proc/<pid>/comm contain a process name we are interested in?
static processlist_t *process_check(int pid) {
- int len, is_match, status;
+ int len, is_match, status
, retval
;
char file[BUFSIZE];
FILE *fh;
char buffer[BUFSIZE];
char file[BUFSIZE];
FILE *fh;
char buffer[BUFSIZE];
@@
-122,7
+122,13
@@
static processlist_t *process_check(int pid) {
return NULL;
}
return NULL;
}
- fscanf(fh, "%[^\n]", buffer);
+ retval = fscanf(fh, "%[^\n]", buffer);
+
+ if (retval < 0) {
+ WARNING("procevent process_check: unable to read comm file for pid %d",
+ pid);
+ return NULL;
+ }
//
// Go through the processlist linked list and look for the process name
//
// Go through the processlist linked list and look for the process name