From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 382A5138350 for ; Wed, 22 Jan 2020 19:54:06 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5F949E086D; Wed, 22 Jan 2020 19:54:05 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 397CDE086C for ; Wed, 22 Jan 2020 19:54:05 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0806A34E37F for ; Wed, 22 Jan 2020 19:54:04 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 89965ED for ; Wed, 22 Jan 2020 19:54:02 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1579721762.1c0e24930af5f445d8c633791eb3ea2317b82b68.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qpkg.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 1c0e24930af5f445d8c633791eb3ea2317b82b68 X-VCS-Branch: master Date: Wed, 22 Jan 2020 19:54:02 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 8affdaa4-bf55-4800-9515-08faffb7ccff X-Archives-Hash: 5d8c2addd92af81a9b5e50d051e10bf3 commit: 1c0e24930af5f445d8c633791eb3ea2317b82b68 Author: Fabian Groffen gentoo org> AuthorDate: Wed Jan 22 19:36:02 2020 +0000 Commit: Fabian Groffen gentoo 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 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 */