commit:     1c0e24930af5f445d8c633791eb3ea2317b82b68
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 19:36:02 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 19:36:02 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=1c0e2493

qpkg: fix Coverity 125896 Unchecked return value

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 419456c..4519e9c 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -251,7 +251,11 @@ qpkg_make(depend_atom *atom)
        pclose(fp);
 
        /* get offset where xpak will start */
-       stat(tbz2, &st);
+       if (stat(tbz2, &st) == -1) {
+               warnp("could not stat '%s': %s", tbz2, strerror(errno));
+               free(buf);
+               return 1;
+       }
        xpaksize = st.st_size;
 
        snprintf(buf, buflen, "%s/%s/%s",
@@ -260,7 +264,12 @@ qpkg_make(depend_atom *atom)
        xpak_argv[1] = NULL;
        xpak_create(AT_FDCWD, tbz2, 1, xpak_argv, 1, verbose);
 
-       stat(tbz2, &st);
+       /* calculate the number of bytes taken by the xpak archive */
+       if (stat(tbz2, &st) == -1) {
+               warnp("could not stat '%s': %s", tbz2, strerror(errno));
+               free(buf);
+               return 1;
+       }
        xpaksize = st.st_size - xpaksize;
 
        /* save tbz2 tail: OOOOSTOP */

Reply via email to