From e763cfbf76e733028ca4f996d94bb96317732ad9 Mon Sep 17 00:00:00 2001 From: RainRat Date: Fri, 17 Nov 2023 18:00:00 -0800 Subject: [PATCH 1/3] Update allow_list.c potential memory leak https://github.com/Cisco-Talos/clamav/issues/1092 --- clamav-milter/allow_list.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clamav-milter/allow_list.c b/clamav-milter/allow_list.c index 09f37ff560..fed7ff512a 100644 --- a/clamav-milter/allow_list.c +++ b/clamav-milter/allow_list.c @@ -157,12 +157,14 @@ int smtpauth_init(const char *r) if (len <= 0) continue; if (len * 3 + 1 > rxavail) { ptr = regex; - regex = realloc(regex, rxsize + 2048); - if (!regex) { + char *temp = realloc(regex, rxsize + 2048); + if (!temp) { + free(regex); logg(LOGG_ERROR, "Cannot allocate memory for SkipAuthenticated file\n"); fclose(f); return 1; } + regex = temp; rxavail = 2048; rxsize += 2048; if (!ptr) { From af6fb3884035e8fd169f4ea8fee273bfe65a9d69 Mon Sep 17 00:00:00 2001 From: Micah Snyder Date: Thu, 30 Nov 2023 18:23:08 -0500 Subject: [PATCH 2/3] Update clamav-milter/allow_list.c --- clamav-milter/allow_list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clamav-milter/allow_list.c b/clamav-milter/allow_list.c index fed7ff512a..c9b48c557a 100644 --- a/clamav-milter/allow_list.c +++ b/clamav-milter/allow_list.c @@ -156,7 +156,7 @@ int smtpauth_init(const char *r) } if (len <= 0) continue; if (len * 3 + 1 > rxavail) { - ptr = regex; + ptr = regex; char *temp = realloc(regex, rxsize + 2048); if (!temp) { free(regex); From c3c4165b739ec20eda834eaf5158d897b309d823 Mon Sep 17 00:00:00 2001 From: Micah Snyder Date: Thu, 30 Nov 2023 18:30:13 -0500 Subject: [PATCH 3/3] squashme --- clamav-milter/allow_list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clamav-milter/allow_list.c b/clamav-milter/allow_list.c index c9b48c557a..50f9ed2bd0 100644 --- a/clamav-milter/allow_list.c +++ b/clamav-milter/allow_list.c @@ -164,7 +164,7 @@ int smtpauth_init(const char *r) fclose(f); return 1; } - regex = temp; + regex = temp; rxavail = 2048; rxsize += 2048; if (!ptr) {