pgpool2.git / summary / log / commit / refs
commit 42499fe2e618afdc110acb0180490b431bc7123e
Author: Tatsuo Ishii <ishii@postgresql.org>
Date: Tue Dec 06 01:32:49 2011 +0000
Fix add_regex_pattern(). It does not allocate enough memory for each
black/white_function_list items. The function adds "^" and "$" to each
function items which do not contain those characters. Unfortunately
the function forgot to add extra 2 bytes for those characters. This
may lead to memory corruption errors when pgpool starting up.
pool_config.c | 2 +-
pool_config.l | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/pool_config.c b/pool_config.c
index 30145c15d..c6fc4f6fb 100644
--- a/pool_config.c
+++ b/pool_config.c
@@ -1998,7 +1998,7 @@ int add_regex_pattern(char *type, char *s)
currItem.flag = regex_flags;
/* Fill pattern array */
- currItem.pattern = malloc(sizeof(char)*(strlen(s)+1));
+ currItem.pattern = malloc(sizeof(char)*(strlen(s)+3));
if (currItem.pattern == NULL)
{
pool_error("add_to_patterns: unable to allocate new pattern");
diff --git a/pool_config.l b/pool_config.l
index b01278470..ade40e231 100644
--- a/pool_config.l
+++ b/pool_config.l
@@ -273,7 +273,7 @@ int add_regex_pattern(char *type, char *s)
currItem.flag = regex_flags;
/* Fill pattern array */
- currItem.pattern = malloc(sizeof(char)*(strlen(s)+1));
+ currItem.pattern = malloc(sizeof(char)*(strlen(s)+3));
if (currItem.pattern == NULL)
{
pool_error("add_to_patterns: unable to allocate new pattern");
[parent: 82a331cf13e1]