audit/backport-last-part-of-NULL-pointer-checks.patch
xuraoqing ea72bf0c59 backport patches to fix bug
Signed-off-by: xuraoqing <609179072@qq.com>
2024-06-19 08:49:44 +08:00

54 lines
1.3 KiB
Diff

From 97f3c78b6b31126c1128927d9c85bb794a1efa17 Mon Sep 17 00:00:00 2001
From: Yugend <jugendd@mail.ru>
Date: Fri, 15 Mar 2024 18:13:36 +0300
Subject: [PATCH] last part of NULL pointer checks
Reference:https://github.com/linux-audit/audit-userspace/commit/97f3c78b6b31126c1128927d9c85bb794a1efa17
Conflict:auparse/interpret.c
---
auparse/interpret.c | 4 ++++
src/ausearch-lookup.c | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/auparse/interpret.c b/auparse/interpret.c
index cc03a15..19934a2 100644
--- a/auparse/interpret.c
+++ b/auparse/interpret.c
@@ -415,6 +415,9 @@ int load_interpretation_list(const char *buffer)
return 0;
buf = strdup(buffer);
+ if (buf == NULL) {
+ goto err_out;
+ }
if (strncmp(buf, "SADDR=", 6) == 0) {
// We have SOCKADDR record. It has no other values.
// Handle it by itself.
@@ -431,6 +434,7 @@ int load_interpretation_list(const char *buffer)
return 1;
}
}
+err_out:
free(buf);
return 0;
} else {
diff --git a/src/ausearch-lookup.c b/src/ausearch-lookup.c
index dd58c36..8ff881e 100644
--- a/src/ausearch-lookup.c
+++ b/src/ausearch-lookup.c
@@ -304,6 +304,10 @@ char *unescape(const char *buf)
return NULL;
str = strndup(buf, ptr - buf);
+ if (str == NULL) {
+ fprintf(stderr, "Memory alocation error");
+ return NULL;
+ }
if (*buf == '(')
return str;
--
2.33.0