NSCA memleak fix

Mark Ferlatte ferlatte at cryptio.net
Sat Oct 25 01:18:25 CEST 2003


Mark Ferlatte said on Fri, Oct 24, 2003 at 03:43:17PM -0700:
> Fix for a fairly nasty memory leak in the nsca daemon.  Without this patch,
> nsca was growing to ~80MB overnight under my (~1000 passive check) loads.

Crap, the previous patch was totally broken if you weren't using crypto.

New patch attached.

M
-------------- next part --------------
Index: utils.c
===================================================================
RCS file: /cvsroot/nagios/nsca/src/utils.c,v
retrieving revision 1.4
diff -u -r1.4 utils.c
--- utils.c	15 Oct 2003 23:17:46 -0000	1.4
+++ utils.c	24 Oct 2003 23:08:29 -0000
@@ -252,8 +252,18 @@
 
 #ifdef HAVE_LIBMCRYPT
         /* mcrypt cleanup */
-        if(encryption_method!=ENCRYPT_NONE && encryption_method!=ENCRYPT_XOR)
-                mcrypt_generic_end(CI->td);
+        if(encryption_method!=ENCRYPT_NONE && 
+						encryption_method!=ENCRYPT_XOR) {
+        	mcrypt_generic_end(CI->td);
+					free(CI->key);
+					CI->key = NULL;
+					free(CI->IV);
+					CI->IV = NULL;
+					free(CI->mcrypt_algorithm);
+					CI->mcrypt_algorithm = NULL;
+					free(CI->mcrypt_mode);
+					CI->mcrypt_mode = NULL;
+				}
 #endif
 
         free(CI);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20031024/546af657/attachment.sig>


More information about the Developers mailing list