From df3a304447a7023e7aace0f38879539c002bee2f Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 3 Jan 2009 15:30:56 +0000 Subject: [PATCH] Fix CID 1182: ensure to check return of read() for failure. This commit was SVN r20191. --- opal/mca/pstat/linux/pstat_linux_module.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/opal/mca/pstat/linux/pstat_linux_module.c b/opal/mca/pstat/linux/pstat_linux_module.c index 49a1840701..b8cad57131 100644 --- a/opal/mca/pstat/linux/pstat_linux_module.c +++ b/opal/mca/pstat/linux/pstat_linux_module.c @@ -117,6 +117,10 @@ static int query(pid_t pid, opal_pstats_t *stats) */ memset(data, 0, sizeof(data)); len = read(fd, data, sizeof(data)-1); + if (len < 0) { + /* This shouldn't happen! */ + return OPAL_ERR_FILE_OPEN_FAILURE; + } close(fd); /* remove newline at end */