aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2024-01-02 14:07:45 +0100
committerFabian Groffen <grobian@gentoo.org>2024-01-02 14:07:45 +0100
commitaf1d54e9a8bf517e566091a8c60762ebfcb534d7 (patch)
tree9dc7d565eb485cdb126fc840620050ee6db6a04b
parentbuildsys: regen (diff)
downloadportage-utils-af1d54e9a8bf517e566091a8c60762ebfcb534d7.tar.gz
portage-utils-af1d54e9a8bf517e566091a8c60762ebfcb534d7.tar.bz2
portage-utils-af1d54e9a8bf517e566091a8c60762ebfcb534d7.zip
qmerge: fix Coverity 190455 Argument cannot be negative
Handle case where image dir somehow could not be opened. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
-rw-r--r--qmerge.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/qmerge.c b/qmerge.c
index b16b4b5..8924a37 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1411,10 +1411,12 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
int imagefd = open("image", O_RDONLY);
size_t masklen = strlen(install_mask) + 1 +
15 + 1 + 14 + 1 + 14 + 1 + 1; /* worst case scenario */
- char *imask = xmalloc(masklen);
+ char *imask;
size_t maskp;
- if (fstat(imagefd, &st) == -1) {
+ if (imagefd == -1) {
+ err("Failed to open image dir");
+ } else if (fstat(imagefd, &st) == -1) {
close(imagefd);
err("Cannot stat image dirfd");
} else if (eprefix != NULL && eprefix[0] == '/') {
@@ -1425,6 +1427,7 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
}
}
+ imask = xmalloc(masklen);
/* rely on INSTALL_MASK code to remove optional dirs */
maskp = snprintf(imask, masklen, "%s ", install_mask);
if (contains_set("noinfo", features))