pstat linux: ensure read() returns >=0
This was CID 71182.
Этот коммит содержится в:
родитель
27a783b1c3
Коммит
6a64fe85a1
@ -9,7 +9,7 @@
|
|||||||
* University of Stuttgart. All rights reserved.
|
* University of Stuttgart. All rights reserved.
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* 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 Los Alamos National Security, LLC. All rights reserved.
|
||||||
* Copyright (c) 2013 Intel, Inc. 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));
|
memset(data, 0, sizeof(data));
|
||||||
len = read(fd, data, sizeof(data)-1);
|
len = read(fd, data, sizeof(data)-1);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
if (len < 0) {
|
||||||
|
goto diskstats;
|
||||||
|
}
|
||||||
|
|
||||||
/* remove newline at end */
|
/* remove newline at end */
|
||||||
data[len] = '\0';
|
data[len] = '\0';
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user