[CRIU] [PATCH 2/2] namespace: use ferror() to detect errors of fscanf()

Andrei Vagin avagin at openvz.org
Wed Feb 1 09:53:39 PST 2017


From: Andrei Vagin <avagin at virtuozzo.com>

Currently we check errno, but musl-libc doesn't zero it,
if fscanf() has returned EOF without errors.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/namespaces.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/criu/namespaces.c b/criu/namespaces.c
index f655c16..b1cca98 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -750,8 +750,8 @@ static int parse_id_map(pid_t pid, char *name, UidGidExtent ***pb_exts)
 		ret = fscanf(f, "%d %d %d", &ext->first,
 				&ext->lower_first, &ext->count);
 		if (ret != 3) {
-			if (errno != 0) {
-				pr_perror("Unable to parse extents");
+			if (ferror(f)) {
+				pr_perror("Unable to parse extents: %d", ret);
 				ret = -1;
 			} else
 				ret = 0;
-- 
2.7.4



More information about the CRIU mailing list