audit/backport-update-error-messages-in-NULL-Checks.patch
2024-07-23 11:08:29 +08:00

280 lines
9.3 KiB
Diff

From dc7450f2fd056c7ca5eb29182ccb30ec0a4228c5 Mon Sep 17 00:00:00 2001
From: Yugend <jugendd@mail.ru>
Date: Fri, 22 Mar 2024 14:01:59 +0300
Subject: [PATCH] update error messages in NULL Checks
Reference:https://github.com/linux-audit/audit-userspace/commit/dc7450f2fd056c7ca5eb29182ccb30ec0a4228c5
Conflict:auparse/auparse.c,src/ausearch-nvpair.c
---
audisp/audispd-llist.c | 1 +
audisp/plugins/zos-remote/zos-remote-queue.c | 2 +-
audisp/queue.c | 2 +-
auparse/auparse.c | 2 +-
auparse/normalize-llist.c | 1 +
auparse/normalize.c | 4 ++--
lib/gen_tables.c | 4 ++--
src/auditctl-llist.c | 1 +
src/auditctl.c | 2 +-
src/ausearch-avc.c | 1 +
src/ausearch-int.c | 1 +
src/ausearch-llist.c | 1 +
src/ausearch-lol.c | 6 +++---
src/ausearch-lookup.c | 2 +-
src/ausearch-nvpair.c | 1 +
src/ausearch-string.c | 1 +
tools/aulastlog/aulastlog-llist.c | 1 +
17 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/audisp/audispd-llist.c b/audisp/audispd-llist.c
index c338327..30d7f03 100644
--- a/audisp/audispd-llist.c
+++ b/audisp/audispd-llist.c
@@ -75,6 +75,7 @@ void plist_append(conf_llist *l, plugin_conf_t *p)
newnode = malloc(sizeof(lnode));
if (newnode == NULL) {
+ printf("Out of memory. Check %s file, %d line", __FILE__, __LINE__);
return;
}
diff --git a/audisp/plugins/zos-remote/zos-remote-queue.c b/audisp/plugins/zos-remote/zos-remote-queue.c
index f801989..67397f3 100644
--- a/audisp/plugins/zos-remote/zos-remote-queue.c
+++ b/audisp/plugins/zos-remote/zos-remote-queue.c
@@ -131,7 +131,7 @@ void increase_queue_depth(unsigned int size)
tmp_q = realloc(q, size * sizeof(BerElement *));
if (tmp_q == NULL) {
- log_err("Memory allocation error");;
+ log_err("Out of memory. Check %s file, %d line", __FILE__, __LINE__);
pthread_mutex_unlock(&queue_lock);
return;
}
diff --git a/audisp/queue.c b/audisp/queue.c
index bf60600..ce27183 100644
--- a/audisp/queue.c
+++ b/audisp/queue.c
@@ -222,7 +222,7 @@ void increase_queue_depth(unsigned int size)
tmp_q = realloc(q, size * sizeof(event_t *));
if (tmp_q == NULL) {
- fprintf(stderr, "Memory allocation error");
+ fprintf(stderr, "Out of Memory. Check %s file, %d line", __FILE__, __LINE__);
pthread_mutex_unlock(&queue_lock);
return;
}
diff --git a/auparse/auparse.c b/auparse/auparse.c
index 652204e..479edc5 100644
--- a/auparse/auparse.c
+++ b/auparse/auparse.c
@@ -94,7 +94,7 @@ static int setup_log_file_array(auparse_state_t *au)
num--;
tmp = malloc((num+2)*sizeof(char *));
if (!tmp) {
- fprintf(stderr, "No memory\n");
+ fprintf(stderr, "Out of memory. Check %s file, %d line", __FILE__, __LINE__);
free_config(&config);
free(filename);
return 1;
diff --git a/auparse/normalize-llist.c b/auparse/normalize-llist.c
index 32d5f12..433c457 100644
--- a/auparse/normalize-llist.c
+++ b/auparse/normalize-llist.c
@@ -67,6 +67,7 @@ void cllist_append(cllist *l, uint32_t num, void *data)
newnode = malloc(sizeof(data_node));
if (newnode == NULL) {
+ printf("Out of memory. Check %s file, %d line", __FILE__, __LINE__);
return;
}
diff --git a/auparse/normalize.c b/auparse/normalize.c
index eb06f6d..a221d44 100644
--- a/auparse/normalize.c
+++ b/auparse/normalize.c
@@ -1062,7 +1062,7 @@ static int normalize_compound(auparse_state_t *au)
const char *exe = auparse_interpret_field(au);
D.how = strdup(exe);
if (D.how == NULL) {
- fprintf(stderr, "Memory allocation error");
+ fprintf(stderr, "Out of memory. Check %s file, %d line", __FILE__, __LINE__);
free((void *)syscall);
return 1;
}
@@ -1727,7 +1727,7 @@ map:
const char *exe = auparse_interpret_field(au);
D.how = strdup(exe);
if (D.how == NULL) {
- fprintf(stderr, "Memory allocation error");
+ fprintf(stderr, "Out of memory. Check %s file, %d line", __FILE__, __LINE__);
return 1;
}
if ((strncmp(D.how, "/usr/bin/python", 15) == 0) ||
diff --git a/lib/gen_tables.c b/lib/gen_tables.c
index 4ff233d..a2930ff 100644
--- a/lib/gen_tables.c
+++ b/lib/gen_tables.c
@@ -272,7 +272,7 @@ output_i2s(const char *prefix)
unique_values = malloc(NUM_VALUES * sizeof(*unique_values));
if (unique_values == NULL) {
- fprintf(stderr, "Memory allocation error");
+ fprintf(stderr, "Out of memory. Check %s file, %d line", __FILE__, __LINE__);
abort();
}
n = 0;
@@ -355,7 +355,7 @@ output_i2s_transtab(const char *prefix)
}
uc_prefix = strdup(prefix);
if (uc_prefix == NULL) {
- fprintf(stderr, "Memory allocation error");
+ fprintf(stderr, "Out of memory. Check %s file, %d line", __FILE__, __LINE__);
abort();
}
for (i = 0; uc_prefix[i] != '\0'; i++)
diff --git a/src/auditctl-llist.c b/src/auditctl-llist.c
index ae9776b..481502d 100644
--- a/src/auditctl-llist.c
+++ b/src/auditctl-llist.c
@@ -65,6 +65,7 @@ void list_append(llist *l, struct audit_rule_data *r, size_t sz)
newnode = malloc(sizeof(lnode));
if (newnode == NULL) {
+ printf("Out of memory. Check %s file, %d line", __FILE__, __LINE__);
return;
}
diff --git a/src/auditctl.c b/src/auditctl.c
index f0d12bd..81ca2b8 100644
--- a/src/auditctl.c
+++ b/src/auditctl.c
@@ -1326,7 +1326,7 @@ static int fileopt(const char *file)
i = 0;
fields = malloc(nf * sizeof(char *));
if (fields == NULL) {
- audit_msg(LOG_ERR, "Memory allocation error");
+ audit_msg(LOG_ERR, "Out of memory. Check %s file, %d line", __FILE__, __LINE__);
return 1;
}
diff --git a/src/ausearch-avc.c b/src/ausearch-avc.c
index 6aa98c7..3857656 100644
--- a/src/ausearch-avc.c
+++ b/src/ausearch-avc.c
@@ -68,6 +68,7 @@ void alist_append(alist *l, anode *node)
newnode = malloc(sizeof(anode));
if (newnode == NULL) {
+ printf("Out of memory. Check %s file, %d line", __FILE__, __LINE__);
return;
}
diff --git a/src/ausearch-int.c b/src/ausearch-int.c
index 0e8b0ff..5f57b05 100644
--- a/src/ausearch-int.c
+++ b/src/ausearch-int.c
@@ -47,6 +47,7 @@ void ilist_append(ilist *l, int num, unsigned int hits, int aux)
newnode = malloc(sizeof(int_node));
if (newnode == NULL) {
+ printf("Out of memory. Check %s file, %d line", __FILE__, __LINE__);
return;
}
diff --git a/src/ausearch-llist.c b/src/ausearch-llist.c
index 3b4ff26..24e816b 100644
--- a/src/ausearch-llist.c
+++ b/src/ausearch-llist.c
@@ -108,6 +108,7 @@ void list_append(llist *l, lnode *node)
newnode = malloc(sizeof(lnode));
if (newnode == NULL) {
+ printf("Out of memory. Check %s file, %d line", __FILE__, __LINE__);
return;
}
diff --git a/src/ausearch-lol.c b/src/ausearch-lol.c
index 24f5731..da302cc 100644
--- a/src/ausearch-lol.c
+++ b/src/ausearch-lol.c
@@ -43,7 +43,7 @@ void lol_create(lol *lo)
lo->limit = ARRAY_LIMIT;
lo->array = (lolnode *)malloc(size);
if (lo->array == NULL) {
- fprintf(stderr, "Memory allocation error");
+ fprintf(stderr, "Out of memory. Check %s file, %d line", __FILE__, __LINE__);
lo->limit = 0;
return;
}
@@ -305,7 +305,7 @@ int lol_add_record(lol *lo, char *buff)
n.type = e.type;
n.message = strdup(buff);
if(n.message == NULL) {
- fprintf(stderr, "Memory allocation error");
+ fprintf(stderr, "Out of memory. Check %s file, %d line", __FILE__, __LINE__);
return 0;
}
ptr = strchr(n.message, AUDIT_INTERP_SEPARATOR);
@@ -363,7 +363,7 @@ int lol_add_record(lol *lo, char *buff)
// Create new event and fill it in
l = malloc(sizeof(llist));
if (l == NULL) {
- fprintf(stderr, "Memory allocation error");
+ fprintf(stderr, "Out of memory. Check %s file, %d line", __FILE__, __LINE__);
return 0;
}
list_create(l);
diff --git a/src/ausearch-lookup.c b/src/ausearch-lookup.c
index 6be30f9..3869751 100644
--- a/src/ausearch-lookup.c
+++ b/src/ausearch-lookup.c
@@ -305,7 +305,7 @@ char *unescape(const char *buf)
str = strndup(buf, ptr - buf);
if (str == NULL) {
- fprintf(stderr, "Memory alocation error");
+ fprintf(stderr, "Out of memory. Check %s file, %d line", __FILE__, __LINE__);
return NULL;
}
diff --git a/src/ausearch-nvpair.c b/src/ausearch-nvpair.c
index 52a14c7..1187115 100644
--- a/src/ausearch-nvpair.c
+++ b/src/ausearch-nvpair.c
@@ -46,6 +46,7 @@ void nvlist_append(nvlist *l, nvnode *node)
{
nvnode* newnode = malloc(sizeof(nvnode));
if (newnode == NULL) {
+ printf("Out of memory. Check %s file, %d line", __FILE__, __LINE__);
return;
}
diff --git a/src/ausearch-string.c b/src/ausearch-string.c
index bbac7be..d723ac0 100644
--- a/src/ausearch-string.c
+++ b/src/ausearch-string.c
@@ -67,6 +67,7 @@ void slist_append(slist *l, snode *node)
newnode = malloc(sizeof(snode));
if (newnode == NULL) {
+ printf("Out of memory. Check %s file, %d line", __FILE__, __LINE__);
return;
}
diff --git a/tools/aulastlog/aulastlog-llist.c b/tools/aulastlog/aulastlog-llist.c
index 779afb5..0b89be6 100644
--- a/tools/aulastlog/aulastlog-llist.c
+++ b/tools/aulastlog/aulastlog-llist.c
@@ -47,6 +47,7 @@ void list_append(llist *l, lnode *node)
newnode = malloc(sizeof(lnode));
if (newnode == NULL) {
+ printf("Out of memory. Check %s file, %d line", __FILE__, __LINE__);
return;
}
--
2.33.0