fix memory leak in regex probe (fix #500)

This commit is contained in:
Yves Rutschle committed 2025-06-19 22:31:02 +02:00
1 parent b7556c07bd
commit bd9ed060e4
4 files changed
+15 -7

No files matched your search

+2
View File
@@ -1,6 +1,8 @@
vNEXT:
Fix proxyprotocol target field (Thanks to Github user 404-Not-Found)
Fix memory leak in regex probe.
v2.2.4:
Fix CVE-2025-46806 for "Misaligned Memory Accesses in `is_openvpn_protocol()`"
+5 -7
View File
@@ -21,10 +21,6 @@
#define _GNU_SOURCE
#include <stdio.h>
#ifdef ENABLE_REGEX
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
#endif
#include <regex.h>
#include <ctype.h>
#include "probe.h"
@@ -429,16 +425,18 @@ static int is_msrdp_protocol(const char *p, ssize_t len, struct sslhcfg_protocol
return packet_len == len;
}
#ifdef ENABLE_REGEX
pcre2_match_data* probe_regex_matches;
#endif
static int regex_probe(const char *p, ssize_t len, struct sslhcfg_protocols_item* proto)
{
#ifdef ENABLE_REGEX
pcre2_code**probe = (pcre2_code**)proto->data;
pcre2_match_data* matches;
matches = pcre2_match_data_create(1, NULL);
for (; *probe; probe++) {
int res = pcre2_match(*probe, (PCRE2_SPTR8)p, len, 0, 0, matches, NULL);
int res = pcre2_match(*probe, (PCRE2_SPTR8)p, len, 0, 0, probe_regex_matches, NULL);
if (res >= 0) return 1;
}
+7
View File
@@ -66,4 +66,11 @@ struct sslhcfg_protocols_item* timeout_protocol(void);
void hexdump(msg_info, const char*, unsigned int);
#ifdef ENABLE_REGEX
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
extern pcre2_match_data* probe_regex_matches;
#endif
#endif
+1
View File
@@ -130,6 +130,7 @@ static void setup_regex_probe(struct sslhcfg_protocols_item *p)
exit(1);
}
}
probe_regex_matches = pcre2_match_data_create(1, NULL);
}
#else
{