1 |
commit: 4398c48f77ef4d1c3034549ebf5150f1173341f8 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Jan 19 18:53:52 2020 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Jan 19 18:53:52 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4398c48f |
7 |
|
8 |
qpkg: fix Coverity 206544 Dereference null return value |
9 |
|
10 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
11 |
|
12 |
qpkg.c | 7 ++++++- |
13 |
1 file changed, 6 insertions(+), 1 deletion(-) |
14 |
|
15 |
diff --git a/qpkg.c b/qpkg.c |
16 |
index 562f9af..1eee7b1 100644 |
17 |
--- a/qpkg.c |
18 |
+++ b/qpkg.c |
19 |
@@ -262,7 +262,12 @@ qpkg_make(depend_atom *atom) |
20 |
xpaksize = st.st_size - xpaksize; |
21 |
|
22 |
/* save tbz2 tail: OOOOSTOP */ |
23 |
- fp = fopen(tbz2, "a"); |
24 |
+ if ((fp = fopen(tbz2, "a")) == NULL) { |
25 |
+ warnp("could not open '%s': %s", tbz2, strerror(errno)); |
26 |
+ free(buf); |
27 |
+ return 1; |
28 |
+ } |
29 |
+ |
30 |
WRITE_BE_INT32(buf, xpaksize); |
31 |
fwrite(buf, 1, 4, fp); |
32 |
fwrite("STOP", 1, 4, fp); |