[CRIU] [PATCH] proc_parse: double fclose in parse_fdinfo
Cyrill Gorcunov
gorcunov at openvz.org
Thu Apr 25 06:16:57 EDT 2013
On Thu, Apr 25, 2013 at 02:04:36PM +0400, Vasily Averin wrote:
> "crtools check" crashes on ubuntu 12.10
> (00.011275) Error (proc_parse.c:1049): No records of type 6 found in fdinfo file
> (00.011281) Error (proc_parse.c:1052): parse_fdinfo: error parsing [flags: 02 ] for 6 : Operation not permitted
> *** glibc detected *** /home/vvs/devel/criu/crtools/crtools: double free or corruption (top): 0x000000000068a5a0 **
>
> Signed-off-by: Vasily Averin <vvs at parallels.com>
This looks like a big hammer to me ;) I guess better to introduce
fclose_safe helper (as we have for close_safe()) or some shorter
patch as below.
---
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Thu, 25 Apr 2013 14:14:14 +0400
Subject: [PATCH] proc_parse: Don't close file stream twice
| "crtools check" crashes on ubuntu 12.10
| (00.011275) Error (proc_parse.c:1049): No records of type 6 found in fdinfo file
| (00.011281) Error (proc_parse.c:1052): parse_fdinfo: error parsing [flags: 02 ] for 6 : Operation not permitted
| *** glibc detected *** /home/vvs/devel/criu/crtools/crtools: double free or corruption (top): 0x000000000068a5a0 **
Reported-by: Vasily Averin <vvs at parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
proc_parse.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/proc_parse.c b/proc_parse.c
index 6920bd4..f372c69 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -1035,16 +1035,19 @@ int parse_fdinfo(int fd, int type,
}
}
- fclose(f);
-
- if (entry_met)
+ if (entry_met) {
+ fclose(f);
return 0;
+ }
+
/*
* An eventpoll/inotify file may have no target fds set thus
* resulting in no tfd: lines in proc. This is normal.
*/
- if (type == FD_TYPES__EVENTPOLL || type == FD_TYPES__INOTIFY)
+ if (type == FD_TYPES__EVENTPOLL || type == FD_TYPES__INOTIFY) {
+ fclose(f);
return 0;
+ }
pr_err("No records of type %d found in fdinfo file\n", type);
parse_err:
--
1.8.1.4
More information about the CRIU
mailing list