Skip to content

Commit 98d3b73

Browse files
committed
Fix static analysis findings
1 parent 9a0bb0f commit 98d3b73

7 files changed

Lines changed: 19 additions & 16 deletions

File tree

audisp/plugins/filter/audisp-filter.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ static void handle_event(auparse_state_t* au, auparse_cb_event_t cb_event_type,
9595
hup = 0;
9696
ausearch_clear(au);
9797
}
98-
ausearch_set_stop(au, AUSEARCH_STOP_EVENT);
98+
if (ausearch_set_stop(au, AUSEARCH_STOP_EVENT))
99+
return; // impossible, doing this for static analysis
100+
99101
for (struct filter_rule *rule = list.head; rule;
100102
rule = rule->next) {
101103
int rc = ausearch_add_expression(au, rule->expr, &error,

audisp/plugins/remote/audisp-remote.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -962,16 +962,17 @@ static int negotiate_credentials (void)
962962
if (config.krb5_principal == NULL) {
963963
const char *name = config.krb5_client_name ?
964964
config.krb5_client_name : "auditd";
965-
config.krb5_principal = (char *) malloc (strlen (name) + 1
966-
+ strlen (config.remote_server) + 1);
967-
sprintf((char *)config.krb5_principal, "%s@%s",
965+
size_t length = strlen(name) + 1 +
966+
strlen(config.remote_server) + 1;
967+
config.krb5_principal = malloc(length);
968+
snprintf(config.krb5_principal, length, "%s@%s",
968969
name, config.remote_server);
969970
}
970-
slashptr = strchr (config.krb5_principal, '/');
971+
slashptr = strchr(config.krb5_principal, '/');
971972
if (slashptr)
972973
*slashptr = '@';
973974

974-
name_buf.value = (char *)config.krb5_principal;
975+
name_buf.value = config.krb5_principal;
975976
name_buf.length = strlen(name_buf.value) + 1;
976977
major_status = gss_import_name(&minor_status, &name_buf,
977978
(gss_OID) gss_nt_service_name, &service_name_e);

audisp/plugins/zos-remote/zos-remote-queue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ BerElement *dequeue(void)
9898
/* Wait until its got something in it */
9999
pthread_mutex_lock(&queue_lock);
100100
n = q_last%q_depth;
101-
if (q[n] == NULL) {
101+
while (q[n] == NULL) {
102102
pthread_cond_wait(&queue_nonempty, &queue_lock);
103103
n = q_last%q_depth;
104104
}

auparse/interpret.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
typedef enum { AVC_UNSET, AVC_DENIED, AVC_GRANTED } avc_t;
136136
typedef enum { S_UNSET=-1, S_FAILED, S_SUCCESS } success_t;
137137

138-
static char *print_escaped(const char *val);
138+
static char *print_escaped(char *val);
139139
static const char *print_signals(const char *val, unsigned int base);
140140

141141
/*
@@ -145,7 +145,7 @@ static const char *print_signals(const char *val, unsigned int base);
145145
static unsigned char x2c(const unsigned char *buf)
146146
{
147147
static const char AsciiArray[17] = "0123456789ABCDEF";
148-
char *ptr;
148+
const char *ptr;
149149
unsigned char total=0;
150150

151151
ptr = strchr(AsciiArray, (char)toupper(buf[0]));
@@ -291,9 +291,9 @@ static void escape(const char *s, char *dest, unsigned int len,
291291
}
292292
}
293293

294-
static void key_escape(const char *orig, char *dest, auparse_esc_t escape_mode)
294+
static void key_escape(char *orig, char *dest, auparse_esc_t escape_mode)
295295
{
296-
const char *optr = orig;
296+
char *optr = orig;
297297
char *str, *dptr = dest, tmp;
298298
while (*optr) {
299299
unsigned int klen, cnt;
@@ -904,7 +904,7 @@ static const char *print_exit(const char *val)
904904
return strdup(val);
905905
}
906906

907-
static char *print_escaped(const char *val)
907+
static char *print_escaped(char *val)
908908
{
909909
char *out;
910910

src/auditd-config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ const char *failure_action_to_str(unsigned int action)
10701070
static int validate_email(const char *acct)
10711071
{
10721072
int i, len;
1073-
char *ptr1;
1073+
const char *ptr1;
10741074

10751075
if (acct == NULL)
10761076
return 2;
@@ -1095,7 +1095,7 @@ static int validate_email(const char *acct)
10951095
}
10961096

10971097
if ((ptr1 = strchr(acct, '@'))) {
1098-
char *ptr2;
1098+
const char *ptr2;
10991099
int rc2;
11001100
struct addrinfo *ai;
11011101
struct addrinfo hints;

src/auditd-config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ struct daemon_conf
9090
unsigned long tcp_client_max_port;
9191
unsigned long tcp_client_max_idle;
9292
int transport;
93-
const char *krb5_principal;
93+
char *krb5_principal; // gssapi code inserts @ sometimes
9494
const char *krb5_key_file;
9595
int distribute_network_events;
9696
// Dispatcher config

src/ausearch-lookup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static int is_hex_string(const char *str)
284284
static unsigned char x2c(unsigned char *buf)
285285
{
286286
static const char AsciiArray[17] = "0123456789ABCDEF";
287-
char *ptr;
287+
const char *ptr;
288288
unsigned char total=0;
289289

290290
ptr = strchr(AsciiArray, (char)toupper(buf[0]));

0 commit comments

Comments
 (0)