audit/backport-Fix-an-auparse-memory-leak-caused-in-recent-glibc.patch

36 lines
953 B
Diff

From 16246878c503d7395ae668817bf629e05361fec5 Mon Sep 17 00:00:00 2001
From: Steve Grubb <sgrubb@redhat.com>
Date: Thu, 29 Jul 2021 18:39:22 -0400
Subject: [PATCH] Fix an auparse memory leak caused in recent glibc
---
auparse/interpret.c | 4 ++++-
1 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/auparse/interpret.c b/auparse/interpret.c
index 2813acb..33c173e 100644
--- a/auparse/interpret.c
+++ b/auparse/interpret.c
@@ -50,6 +50,7 @@
#include <sys/personality.h>
#include <sys/prctl.h>
#include <sched.h>
+#include <limits.h> /* PATH_MAX */
#ifdef USE_FANOTIFY
#include <linux/fanotify.h>
#else
@@ -865,8 +866,10 @@ static const char *print_escaped_ext(const idata *id)
str1 = NULL;
}
errno = 0;
- out = realpath(str3, NULL);
+ out = malloc(PATH_MAX);
+ realpath(str3, out);
if (errno) { // If there's an error, just return the original
+ free(out);
free(str1);
free(str2);
return str3;
--