1 |
commit: 7f610741388d8543d3d7652de4625eaa7caa6dfd |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jan 2 15:32:37 2020 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jan 2 15:32:37 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7f610741 |
7 |
|
8 |
qcheck: fix use after free |
9 |
|
10 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
11 |
|
12 |
qcheck.c | 6 ++++-- |
13 |
1 file changed, 4 insertions(+), 2 deletions(-) |
14 |
|
15 |
diff --git a/qcheck.c b/qcheck.c |
16 |
index 1217a8a..59f35e2 100644 |
17 |
--- a/qcheck.c |
18 |
+++ b/qcheck.c |
19 |
@@ -305,7 +305,6 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv) |
20 |
} |
21 |
free(line); |
22 |
free(buffer); |
23 |
- fclose(fp_contents); |
24 |
|
25 |
if (!state->chk_config_protect) { |
26 |
freeargv(cp_argc, cp_argv); |
27 |
@@ -328,9 +327,12 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv) |
28 |
fclose(fp_contents_update); |
29 |
if (renameat(pkg_ctx->fd, "CONTENTS~", pkg_ctx->fd, "CONTENTS")) |
30 |
unlinkat(pkg_ctx->fd, "CONTENTS~", 0); |
31 |
- if (!verbose) |
32 |
+ if (!verbose) { |
33 |
+ fclose(fp_contents); |
34 |
return EXIT_SUCCESS; |
35 |
+ } |
36 |
} |
37 |
+ fclose(fp_contents); |
38 |
if (state->bad_only && num_files_ok != num_files) |
39 |
printf("%s\n", atom_format(state->fmt, atom)); |
40 |
qcprintf(" %2$s*%1$s %3$s%4$zu%1$s out of %3$s%5$zu%1$s file%6$s are good", |