1
1

pstat linux: ensure read() returns >=0

This was CID 71182.
Этот коммит содержится в:
Jeff Squyres 2015-02-12 09:39:31 -08:00
родитель 27a783b1c3
Коммит 6a64fe85a1

Просмотреть файл

@ -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';