-
Notifications
You must be signed in to change notification settings - Fork 409
SAST checks #2258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
SAST checks #2258
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -329,6 +329,14 @@ int routingtable_probe_main(probe_ctx *ctx, void *arg) | |
switch(probe_ent_getdatatype(dst_ent)) { | ||
case OVAL_DATATYPE_IPV4ADDR: | ||
fp = fopen("/proc/net/route", "r"); | ||
if (fp == NULL) { | ||
if (errno == ENOENT) { | ||
dI("/proc/net/route does not exist. No IPv4 routing table available."); | ||
} else { | ||
dE("Failed to open /proc/net/route: %s", strerror(errno)); | ||
} | ||
break; | ||
} | ||
/* Skip the header line */ | ||
if (getline(&line_buf, &line_len, fp) != -1) { | ||
while(getline(&line_buf, &line_len, fp) != -1) { | ||
|
@@ -346,6 +354,14 @@ int routingtable_probe_main(probe_ctx *ctx, void *arg) | |
break; | ||
case OVAL_DATATYPE_IPV6ADDR: | ||
fp = fopen("/proc/net/ipv6_route", "r"); | ||
if (fp == NULL) { | ||
if (errno == ENOENT) { | ||
dI("/proc/net/route does not exist. No IPv4 routing table available."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IPv6. |
||
} else { | ||
dE("Failed to open /proc/net/route: %s", strerror(errno)); | ||
} | ||
break; | ||
} | ||
|
||
while(getline(&line_buf, &line_len, fp) != -1) { | ||
if (process_line_ip6(line_buf, &rt) != 0) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1097,7 +1097,10 @@ int xiconf_parse_section(xiconf_t *xiconf, xiconf_file_t *xifile, int type, char | |
if (scur->protocol == NULL) { | ||
struct servent *service = getservbyname(scur->name, NULL); | ||
dD("protocol is empty, trying to guess from /etc/services for %s", scur->name); | ||
if (service != NULL) { | ||
if (service == NULL) { | ||
return -1; | ||
} | ||
else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newline. |
||
scur->protocol = strdup(service->s_proto); | ||
dD("service %s has default protocol=%s", scur->name, scur->protocol); | ||
} | ||
|
@@ -1107,7 +1110,10 @@ int xiconf_parse_section(xiconf_t *xiconf, xiconf_file_t *xifile, int type, char | |
if (scur->port == 0) { | ||
struct servent *service = getservbyname(scur->name, scur->protocol); | ||
dD("port not set, trying to guess from /etc/services for %s", scur->name); | ||
if (service != NULL) { | ||
if (service == NULL) { | ||
return -1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also this change is breaking the logic of the probe. Test is failing. |
||
} | ||
else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newline. |
||
if (service->s_port > 0 && service->s_port < 65536) { | ||
scur->port = ntohs((uint16_t)service->s_port); | ||
dD("service %s has default port=%hu/%s", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation.