Yahoo Groups archive

Milter-greylist

Index last updated: 2026-04-28 23:32 UTC

Thread

fix a memory leak in acl.c

fix a memory leak in acl.c

2008-11-10 by Constantine A. Murenin

Hello, 

The patch below fixes a memory leak that has been in milter-greylist 
since acl.c#rev1.41 (2006-12-29).

The alarm was raised as 'Dead Store', 'dead nested assignment' by 
LLVM/Clang Static Analyser, researched and fixed by myself.  :-)

Cheers,
Constantine.						    cnst.su

Index: acl.c
===================================================================
RCS file: /milter-greylist/milter-greylist/acl.c,v
retrieving revision 1.83
diff -u -d -p -4 -r1.83 acl.c
--- acl.c	6 Nov 2008 11:23:53 -0000	1.83
+++ acl.c	10 Nov 2008 01:47:15 -0000
@@ -1657,12 +1657,8 @@ acl_register_entry_first(acl_stage, acl_
 			mg_log(LOG_DEBUG, "Drop ACL %d", conf_line - 1);
 		return NULL;
 	}
 
-	if ((acl = malloc(sizeof(*acl))) == NULL) {
-		mg_log(LOG_ERR, "ACL malloc failed: %s", strerror(errno));
-		exit(EX_OSERR);
-	}
 	acl = gacl;
 	acl->a_type = acl_type;
 	acl->a_stage = acl_stage;
 	acl->a_line = conf_line - 1;

Re: [milter-greylist] fix a memory leak in acl.c

2008-11-10 by manu@netbsd.org

Constantine A. Murenin <mureninc@...> wrote:

> The patch below fixes a memory leak that has been in milter-greylist 
> since acl.c#rev1.41 (2006-12-29).

Um, this is worth a 4.0.2 release :-)

> The alarm was raised as 'Dead Store', 'dead nested assignment' by 
> LLVM/Clang Static Analyser, researched and fixed by myself.  :-)

Do you have more bugs to be fixed in your queue?

-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
manu@...

Re: [milter-greylist] fix a memory leak in acl.c

2008-11-10 by Constantine A. Murenin

On Mon, Nov 10, 2008 at 04:59:41AM +0100, manu@... wrote:
> Constantine A. Murenin <mureninc@...> wrote:
> 
> > The patch below fixes a memory leak that has been in milter-greylist 
> > since acl.c#rev1.41 (2006-12-29).
> 
> Um, this is worth a 4.0.2 release :-)
> 
> > The alarm was raised as 'Dead Store', 'dead nested assignment' by 
> > LLVM/Clang Static Analyser, researched and fixed by myself.  :-)
> 
> Do you have more bugs to be fixed in your queue?

There were some other things found, but no more memory leaks. :)

The only other warning that might be worth fixing is the following:

Index: macro.c
===================================================================
RCS file: /milter-greylist/milter-greylist/macro.c,v
retrieving revision 1.7
diff -u -d -p -4 -r1.7 macro.c
--- macro.c	6 Nov 2007 11:39:33 -0000	1.7
+++ macro.c	10 Nov 2008 04:45:22 -0000
@@ -84,9 +84,8 @@ macro_check(ad, stage, ap, priv)
 {
 	SMFICTX *ctx;
 	struct macro_entry *me;
 	char *value;
-	int extended;
 	int retval = 0;
 
 	ctx = priv->priv_ctx;
 	me = ad->macro;
@@ -102,13 +101,11 @@ macro_check(ad, stage, ap, priv)
 		if (value != NULL && strcmp(value, me->m_string) == 0)
 			retval = 1;
 		break;
 	case M_REGEX:
-		if (value != NULL) {
-			extended = (conf.c_extendedregex ? REG_EXTENDED : 0);
+		if (value != NULL)
 			if (regexec(me->m_regex, value, 0, NULL, 0) == 0)
 				retval = 1;
-		}
 		break;
 	default:
 		mg_log(LOG_ERR, "unexpecte me->m_type = %d", me->m_type);
 		exit(EX_SOFTWARE);

Re: [milter-greylist] fix a memory leak in acl.c

2008-11-10 by Constantine A. Murenin

On 09/11/2008, Constantine A. Murenin <mureninc@...> wrote:
> On Mon, Nov 10, 2008 at 04:59:41AM +0100, manu@... wrote:
>  > Constantine A. Murenin <mureninc@...> wrote:
>  >
>  > > The patch below fixes a memory leak that has been in milter-greylist
>  > > since acl.c#rev1.41 (2006-12-29).
>  >
>  > Um, this is worth a 4.0.2 release :-)
>  >
>  > > The alarm was raised as 'Dead Store', 'dead nested assignment' by
>  > > LLVM/Clang Static Analyser, researched and fixed by myself.  :-)
>  >
>  > Do you have more bugs to be fixed in your queue?
>
>
> There were some other things found, but no more memory leaks. :)
>
>  The only other warning that might be worth fixing is the following:
>
>  Index: macro.c
>  ===================================================================
>  RCS file: /milter-greylist/milter-greylist/macro.c,v
>  retrieving revision 1.7
>  diff -u -d -p -4 -r1.7 macro.c
>  --- macro.c     6 Nov 2007 11:39:33 -0000       1.7
>  +++ macro.c     10 Nov 2008 04:45:22 -0000
>  @@ -84,9 +84,8 @@ macro_check(ad, stage, ap, priv)
>   {
>         SMFICTX *ctx;
>         struct macro_entry *me;
>         char *value;
>  -       int extended;
>         int retval = 0;
>
>         ctx = priv->priv_ctx;
>         me = ad->macro;
>  @@ -102,13 +101,11 @@ macro_check(ad, stage, ap, priv)
>                 if (value != NULL && strcmp(value, me->m_string) == 0)
>                         retval = 1;
>                 break;
>         case M_REGEX:
>  -               if (value != NULL) {
>  -                       extended = (conf.c_extendedregex ? REG_EXTENDED : 0);
>  +               if (value != NULL)
>                         if (regexec(me->m_regex, value, 0, NULL, 0) == 0)
>                                 retval = 1;
>  -               }
>                 break;
>         default:
>                 mg_log(LOG_ERR, "unexpecte me->m_type = %d", me->m_type);
>                 exit(EX_SOFTWARE);

Hi,

I see you've committed a different fix, but now indentation for
"retval = 1;" is wrong. ;)

C.

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.