Skip to content

Commit cb8d27d

Browse files
committed
Fix various issues reported by Coverity
- oval_sexp_to_sysitem: null pointer derefrence - probe_worker: insecure chroot - inetlisteningservers_probe_main: uninitialized memory - rpmverifypackage_additem: invalid type in argument to printf format specifier
1 parent c26da2a commit cb8d27d

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

src/OVAL/oval_sexp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,8 @@ static struct oval_sysitem *oval_sexp_to_sysitem(struct oval_syschar_model *mode
965965
} else {
966966
family = item_name;
967967
char *endptr = strchr(family, ':');
968+
if (endptr == NULL)
969+
goto cleanup;
968970
*endptr = '\0';
969971
name = endptr + 1;
970972
endptr = strrchr(name, '_');

src/OVAL/probes/probe/worker.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,13 +1021,13 @@ SEXP_t *probe_worker(probe_t *probe, SEAP_msg_t *msg_in, int *ret)
10211021
dE("open(\".\") failed: %s", strerror(errno));
10221022
return NULL;
10231023
}
1024-
if (chdir(rootdir) != 0) {
1025-
dE("chdir failed: %s", strerror(errno));
1026-
}
10271024

10281025
if (chroot(rootdir) != 0) {
10291026
dE("chroot failed: %s", strerror(errno));
10301027
}
1028+
if (chdir("/") != 0) {
1029+
dE("chdir failed: %s", strerror(errno));
1030+
}
10311031
/* NOTE: We're running in a different root directory.
10321032
* Unless /proc, /sys are somehow emulated for the new
10331033
* environment, they are not relevant and so are other

src/OVAL/probes/unix/linux/inetlisteningservers_probe.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,10 @@ int inetlisteningservers_probe_main(probe_ctx *ctx, void *arg)
559559

560560
object = probe_ctx_getobject(ctx);
561561
struct server_info *req = malloc(sizeof(struct server_info));
562+
if (req == NULL)
563+
return 0;
564+
memset(req, 0, sizeof(*req));
565+
562566
req->protocol_ent = probe_obj_getent(object, "protocol", 1);
563567
if (req->protocol_ent == NULL) {
564568
err = PROBE_ENOVAL;

src/OVAL/probes/unix/linux/rpmverifypackage_probe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ static int rpmverifypackage_additem(probe_ctx *ctx, struct rpmverify_res *res)
428428
SEXP_free(value);
429429
}
430430
if (res->vflags & VERIFY_SCRIPT) {
431-
dD("VERIFY_SCRIPT %d", res->vresults & VERIFY_SCRIPT);
431+
dD("VERIFY_SCRIPT %lu", res->vresults & VERIFY_SCRIPT);
432432
value = probe_entval_from_cstr(OVAL_DATATYPE_BOOLEAN, (res->vresults & VERIFY_SCRIPT ? "1" : "0"), 1);
433433
probe_item_ent_add(item, "verification_script_successful", NULL, value);
434434
SEXP_free(value);

0 commit comments

Comments
 (0)