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

Andrei Vagin avagin at openvz.org
Wed Jan 25 13:06:10 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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/criu/namespaces.c b/criu/namespaces.c
index 9f25012..2709587 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -750,7 +750,7 @@ 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) {
+			if (ferror(f)) {
 				pr_perror("Unable to parse extents: %d", ret);
 				ret = -1;
 			} else
-- 
2.7.4



More information about the CRIU mailing list