commit: 44ea638f9e890570bee8c7e9cbef156164180bb0
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 26 17:13:35 2026 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jan 26 17:13:35 2026 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=44ea638f
q: check return of open() before we call fstat, CID 557238
Coverity gets itches when fstat() can be passed a negative value.
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
q.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/q.c b/q.c
index cfc391f7..546afefc 100644
--- a/q.c
+++ b/q.c
@@ -827,6 +827,12 @@ int q_main(int argc, char **argv)
/* now open it */
fd = open(buf, O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
/* 0644 */);
+ if (fd < 0)
+ {
+ warnp("failed to open gtree for writing at %s",
buf);
+ tree_close(t);
+ continue;
+ }
a = archive_write_new();
archive_write_set_format_ustar(a); /* GLEP-78, just to
be safe */