In get_process_info(), the call to get_raw_process_info() for the
parent process did not check the return value. If the call failed
(e.g., parent process no longer exists), the uninitialized parent
struct would be used in strcmp() and other operations, leading to
undefined behavior.
Fix by checking the return value and returning early on failure.
Found with clang analyze.
Fixes: ff1d2c1626b2 ("process: Consolidate process related APIs.")
Signed-off-by: Mike Pattrick <[email protected]>
---
lib/process.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/process.c b/lib/process.c
index b5ec02823..e86437ab4 100644
--- a/lib/process.c
+++ b/lib/process.c
@@ -510,7 +510,9 @@ get_process_info(pid_t pid, struct process_info *pinfo)
if (child.ppid) {
struct raw_process_info parent;
- get_raw_process_info(child.ppid, &parent);
+ if (!get_raw_process_info(child.ppid, &parent)) {
+ return false;
+ }
if (!strcmp(child.name, parent.name)) {
pinfo->booted = parent.uptime;
pinfo->crashes = count_crashes(child.ppid);
--
2.53.0
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev