1 |
commit: 1c0e24930af5f445d8c633791eb3ea2317b82b68 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Jan 22 19:36:02 2020 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Jan 22 19:36:02 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=1c0e2493 |
7 |
|
8 |
qpkg: fix Coverity 125896 Unchecked return value |
9 |
|
10 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
11 |
|
12 |
qpkg.c | 13 +++++++++++-- |
13 |
1 file changed, 11 insertions(+), 2 deletions(-) |
14 |
|
15 |
diff --git a/qpkg.c b/qpkg.c |
16 |
index 419456c..4519e9c 100644 |
17 |
--- a/qpkg.c |
18 |
+++ b/qpkg.c |
19 |
@@ -251,7 +251,11 @@ qpkg_make(depend_atom *atom) |
20 |
pclose(fp); |
21 |
|
22 |
/* get offset where xpak will start */ |
23 |
- stat(tbz2, &st); |
24 |
+ if (stat(tbz2, &st) == -1) { |
25 |
+ warnp("could not stat '%s': %s", tbz2, strerror(errno)); |
26 |
+ free(buf); |
27 |
+ return 1; |
28 |
+ } |
29 |
xpaksize = st.st_size; |
30 |
|
31 |
snprintf(buf, buflen, "%s/%s/%s", |
32 |
@@ -260,7 +264,12 @@ qpkg_make(depend_atom *atom) |
33 |
xpak_argv[1] = NULL; |
34 |
xpak_create(AT_FDCWD, tbz2, 1, xpak_argv, 1, verbose); |
35 |
|
36 |
- stat(tbz2, &st); |
37 |
+ /* calculate the number of bytes taken by the xpak archive */ |
38 |
+ if (stat(tbz2, &st) == -1) { |
39 |
+ warnp("could not stat '%s': %s", tbz2, strerror(errno)); |
40 |
+ free(buf); |
41 |
+ return 1; |
42 |
+ } |
43 |
xpaksize = st.st_size - xpaksize; |
44 |
|
45 |
/* save tbz2 tail: OOOOSTOP */ |