Skip to content

Commit

Permalink
Fix uninitialized variables reported by Coverity
Browse files Browse the repository at this point in the history
  • Loading branch information
0intro committed Sep 20, 2023
1 parent 73d957d commit 1148277
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/OVAL/oval_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -2287,6 +2287,8 @@ static oval_syschar_collection_flag_t _oval_component_evaluate_ARITHMETIC_rec(st
struct oval_value *ov;
char sv[32];

memset(sv, 0, sizeof (sv));

if (datatype == OVAL_DATATYPE_INTEGER) {
snprintf(sv, sizeof (sv), "%ld", (long int) val);
} else if (datatype == OVAL_DATATYPE_FLOAT) {
Expand Down
1 change: 1 addition & 0 deletions src/OVAL/probes/SEAP/seap.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ int SEAP_replyerr (SEAP_CTX_t *ctx, int sd, SEAP_msg_t *rep_msg, uint32_t e)
_A(ctx != NULL);
_A(rep_msg != NULL);

err.type = 0;
err.code = e;
err.id = rep_msg->id;
err.data = NULL; /* FIXME: Attach original message */
Expand Down
3 changes: 3 additions & 0 deletions src/OVAL/probes/probe/icache.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,9 @@ static int probe_cobj_memcheck(size_t item_cnt, double max_ratio)
struct sys_memusage mu_sys;
double c_ratio;

memset(&mu_proc, 0, sizeof(mu_proc));
memset(&mu_sys, 0, sizeof(mu_sys));

if (oscap_proc_memusage (&mu_proc) != 0)
return (-1);

Expand Down
4 changes: 2 additions & 2 deletions src/OVAL/probes/unix/xinetd_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,9 @@ xiconf_t *xiconf_parse(const char *path, unsigned int max_depth)

switch (inctype) {
case XICONF_INCTYPE_FILE:
dD("includefile: %s", pathbuf);
dD("includefile: %s", inclarg);

if (xiconf_add_cfile (xiconf, pathbuf, xifile->depth + 1) != 0) {
if (xiconf_add_cfile (xiconf, inclarg, xifile->depth + 1) != 0) {

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This argument to a file access function is derived from
user input (buffer read by read)
and then passed to xiconf_add_cfile(path), which calls xiconf_read(path), which calls open(__path).
tmpbuf_free(buffer);
continue;
}
Expand Down

0 comments on commit 1148277

Please sign in to comment.