Skip to content

Commit

Permalink
Merge pull request #2047 from 0intro/coverity-various-issues-20231025
Browse files Browse the repository at this point in the history
Fix various issues reported by Coverity
  • Loading branch information
evgenyz authored Nov 7, 2023
2 parents c26da2a + cb8d27d commit 8685ea1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/OVAL/oval_sexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,8 @@ static struct oval_sysitem *oval_sexp_to_sysitem(struct oval_syschar_model *mode
} else {
family = item_name;
char *endptr = strchr(family, ':');
if (endptr == NULL)
goto cleanup;
*endptr = '\0';
name = endptr + 1;
endptr = strrchr(name, '_');
Expand Down
6 changes: 3 additions & 3 deletions src/OVAL/probes/probe/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,13 +1021,13 @@ SEXP_t *probe_worker(probe_t *probe, SEAP_msg_t *msg_in, int *ret)
dE("open(\".\") failed: %s", strerror(errno));
return NULL;
}
if (chdir(rootdir) != 0) {
dE("chdir failed: %s", strerror(errno));
}

if (chroot(rootdir) != 0) {
dE("chroot failed: %s", strerror(errno));
}
if (chdir("/") != 0) {
dE("chdir failed: %s", strerror(errno));
}
/* NOTE: We're running in a different root directory.
* Unless /proc, /sys are somehow emulated for the new
* environment, they are not relevant and so are other
Expand Down
4 changes: 4 additions & 0 deletions src/OVAL/probes/unix/linux/inetlisteningservers_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,10 @@ int inetlisteningservers_probe_main(probe_ctx *ctx, void *arg)

object = probe_ctx_getobject(ctx);
struct server_info *req = malloc(sizeof(struct server_info));
if (req == NULL)
return 0;
memset(req, 0, sizeof(*req));

req->protocol_ent = probe_obj_getent(object, "protocol", 1);
if (req->protocol_ent == NULL) {
err = PROBE_ENOVAL;
Expand Down
2 changes: 1 addition & 1 deletion src/OVAL/probes/unix/linux/rpmverifypackage_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ static int rpmverifypackage_additem(probe_ctx *ctx, struct rpmverify_res *res)
SEXP_free(value);
}
if (res->vflags & VERIFY_SCRIPT) {
dD("VERIFY_SCRIPT %d", res->vresults & VERIFY_SCRIPT);
dD("VERIFY_SCRIPT %lu", res->vresults & VERIFY_SCRIPT);
value = probe_entval_from_cstr(OVAL_DATATYPE_BOOLEAN, (res->vresults & VERIFY_SCRIPT ? "1" : "0"), 1);
probe_item_ent_add(item, "verification_script_successful", NULL, value);
SEXP_free(value);
Expand Down

0 comments on commit 8685ea1

Please sign in to comment.