From 6a64fe85a1a70e7b5b48f998df7918d277ad1877 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 12 Feb 2015 09:39:31 -0800 Subject: [PATCH] pstat linux: ensure read() returns >=0 This was CID 71182. --- opal/mca/pstat/linux/pstat_linux_module.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/opal/mca/pstat/linux/pstat_linux_module.c b/opal/mca/pstat/linux/pstat_linux_module.c index d511ff1684..4d807efef1 100644 --- a/opal/mca/pstat/linux/pstat_linux_module.c +++ b/opal/mca/pstat/linux/pstat_linux_module.c @@ -9,7 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2006-2007 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2013 Los Alamos National Security, LLC. All rights reserved. * Copyright (c) 2013 Intel, Inc. All rights reserved. * @@ -327,6 +327,9 @@ static int query(pid_t pid, memset(data, 0, sizeof(data)); len = read(fd, data, sizeof(data)-1); close(fd); + if (len < 0) { + goto diskstats; + } /* remove newline at end */ data[len] = '\0';