148 lines
4.0 KiB
Diff
148 lines
4.0 KiB
Diff
From b046de44454fa2616dbb8899f1b41d65ce876e33 Mon Sep 17 00:00:00 2001
|
|
From: Yugend <jugendd@mail.ru>
|
|
Date: Fri, 15 Mar 2024 17:08:16 +0300
|
|
Subject: [PATCH] first part of NULL pointer checks
|
|
|
|
Conflict:NA
|
|
Reference:https://github.com/linux-audit/audit-userspace/commit/b046de44454fa2616dbb8899f1b41d65ce876e33
|
|
|
|
---
|
|
audisp/audispd-llist.c | 3 +++
|
|
auparse/auparse.c | 7 +++++++
|
|
src/auditctl-llist.c | 3 +++
|
|
src/auditctl.c | 5 +++++
|
|
src/ausearch-avc.c | 3 +++
|
|
src/ausearch-int.c | 3 +++
|
|
src/ausearch-llist.c | 3 +++
|
|
tools/aulastlog/aulastlog-llist.c | 3 +++
|
|
8 files changed, 30 insertions(+)
|
|
|
|
diff --git a/audisp/audispd-llist.c b/audisp/audispd-llist.c
|
|
index c562a72a..c338327d 100644
|
|
--- a/audisp/audispd-llist.c
|
|
+++ b/audisp/audispd-llist.c
|
|
@@ -74,6 +74,9 @@ void plist_append(conf_llist *l, plugin_conf_t *p)
|
|
lnode* newnode;
|
|
|
|
newnode = malloc(sizeof(lnode));
|
|
+ if (newnode == NULL) {
|
|
+ return;
|
|
+ }
|
|
|
|
if (p) {
|
|
void *pp = malloc(sizeof(struct plugin_conf));
|
|
diff --git a/auparse/auparse.c b/auparse/auparse.c
|
|
index e196373b..516ee8f1 100644
|
|
--- a/auparse/auparse.c
|
|
+++ b/auparse/auparse.c
|
|
@@ -113,6 +113,11 @@ static int setup_log_file_array(auparse_state_t *au)
|
|
}
|
|
num--;
|
|
tmp = malloc((num+2)*sizeof(char *));
|
|
+ if (!tmp) {
|
|
+ fprintf(stderr, "No memory\n");
|
|
+ aup_free_config(&config);
|
|
+ return 1;
|
|
+ }
|
|
|
|
/* Got it, now process logs from last to first */
|
|
if (num > 0)
|
|
@@ -489,6 +494,8 @@ auparse_state_t *auparse_init(ausource_t source, const void *b)
|
|
if (access_ok(b))
|
|
goto bad_exit;
|
|
tmp = malloc(2*sizeof(char *));
|
|
+ if (tmp == NULL)
|
|
+ goto bad_exit;
|
|
tmp[0] = strdup(b);
|
|
tmp[1] = NULL;
|
|
au->source_list = tmp;
|
|
diff --git a/src/auditctl-llist.c b/src/auditctl-llist.c
|
|
index 182d88b5..0f81d4c8 100644
|
|
--- a/src/auditctl-llist.c
|
|
+++ b/src/auditctl-llist.c
|
|
@@ -64,6 +64,9 @@ void list_append(llist *l, const struct audit_rule_data *r, size_t sz)
|
|
lnode* newnode;
|
|
|
|
newnode = malloc(sizeof(lnode));
|
|
+ if (newnode == NULL) {
|
|
+ return;
|
|
+ }
|
|
|
|
if (r) {
|
|
void *rr = malloc(sz);
|
|
diff --git a/src/auditctl.c b/src/auditctl.c
|
|
index dac5118a..ee7e33c8 100644
|
|
--- a/src/auditctl.c
|
|
+++ b/src/auditctl.c
|
|
@@ -1391,6 +1391,11 @@ static int fileopt(const char *file)
|
|
}
|
|
i = 0;
|
|
fields = malloc(nf * sizeof(char *));
|
|
+ if (fields == NULL) {
|
|
+ audit_msg(LOG_ERR, "Memory allocation error");
|
|
+ return 1;
|
|
+ }
|
|
+
|
|
fields[i++] = "auditctl";
|
|
fields[i++] = ptr;
|
|
while( (ptr=audit_strsplit(NULL)) && (i < nf-1)) {
|
|
diff --git a/src/ausearch-avc.c b/src/ausearch-avc.c
|
|
index 10d153f6..6aa98c70 100644
|
|
--- a/src/ausearch-avc.c
|
|
+++ b/src/ausearch-avc.c
|
|
@@ -67,6 +67,9 @@ void alist_append(alist *l, anode *node)
|
|
anode* newnode;
|
|
|
|
newnode = malloc(sizeof(anode));
|
|
+ if (newnode == NULL) {
|
|
+ return;
|
|
+ }
|
|
|
|
if (node->scontext)
|
|
newnode->scontext = node->scontext;
|
|
diff --git a/src/ausearch-int.c b/src/ausearch-int.c
|
|
index 718dacda..0e8b0ffe 100644
|
|
--- a/src/ausearch-int.c
|
|
+++ b/src/ausearch-int.c
|
|
@@ -46,6 +46,9 @@ void ilist_append(ilist *l, int num, unsigned int hits, int aux)
|
|
int_node* newnode;
|
|
|
|
newnode = malloc(sizeof(int_node));
|
|
+ if (newnode == NULL) {
|
|
+ return;
|
|
+ }
|
|
|
|
newnode->num = num;
|
|
newnode->hits = hits;
|
|
diff --git a/src/ausearch-llist.c b/src/ausearch-llist.c
|
|
index 0fa6f671..36fcae6d 100644
|
|
--- a/src/ausearch-llist.c
|
|
+++ b/src/ausearch-llist.c
|
|
@@ -107,6 +107,9 @@ void list_append(llist *l, lnode *node)
|
|
lnode* newnode;
|
|
|
|
newnode = malloc(sizeof(lnode));
|
|
+ if (newnode == NULL) {
|
|
+ return;
|
|
+ }
|
|
|
|
if (node->message)
|
|
newnode->message = node->message;
|
|
diff --git a/tools/aulastlog/aulastlog-llist.c b/tools/aulastlog/aulastlog-llist.c
|
|
index 84882ca8..779afb50 100644
|
|
--- a/tools/aulastlog/aulastlog-llist.c
|
|
+++ b/tools/aulastlog/aulastlog-llist.c
|
|
@@ -46,6 +46,9 @@ void list_append(llist *l, lnode *node)
|
|
lnode* newnode;
|
|
|
|
newnode = malloc(sizeof(lnode));
|
|
+ if (newnode == NULL) {
|
|
+ return;
|
|
+ }
|
|
|
|
newnode->sec = node->sec;
|
|
newnode->uid = node->uid;
|
|
--
|
|
2.33.0
|
|
|