diff options
author | 2024-01-02 14:07:45 +0100 | |
---|---|---|
committer | 2024-01-02 14:07:45 +0100 | |
commit | af1d54e9a8bf517e566091a8c60762ebfcb534d7 (patch) | |
tree | 9dc7d565eb485cdb126fc840620050ee6db6a04b | |
parent | buildsys: regen (diff) | |
download | portage-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.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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)) |