[Oisf-devel] codes mem leak and file handler leak of suricata

Victor Julien victor at inliniac.net
Wed Feb 2 08:25:02 UTC 2011


On 01/26/2011 02:43 AM, iswalker wrote:
> 1. in function alert_debug.c/AlertDebugLogInitCtx, miss deinit function
> 
> OutputCtx *AlertDebugLogInitCtx(ConfNode *conf)
> {
> ..................
> 
>     OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
>     if (output_ctx == NULL)
>         return NULL;
>     output_ctx->data = file_ctx;
>     *output_ctx->DeInit=AlertDebugLogDeInitCtx;  //iswalker:
> AlertDebugLogDeInitCtx function NOT defined,so when engine reload
> dynamicly, file handler will leak*
> 
>     return output_ctx;
> }
> 
> 2.in <http://2.in> alert_xxx.c files,some xxx-log context init function
> like  xxxLogInitCtx,when some codes return NULL,the mem allocated before
> return NULL will NOT free,codes as following:
> 
> OutputCtx *AlertUnifiedLogInitCtx(ConfNode *conf)
> {
>     int ret = 0;
>     LogFileCtx* file_ctx=LogFileNewCtx();
> 
>     if (file_ctx == NULL) {
>         SCLogError(SC_ERR_MEM_ALLOC, "Couldn't create new file_ctx");
>         return NULL;
>     }
> 
>    
>     i
>     file_ctx->size_limit = limit * 1024 * 1024;
> 
>     ret = AlertUnifiedLogOpenFileCtx(file_ctx, filename);
>     if (ret < 0){
> *        LogFileFreeCtx(logfile_ctx); //iswalker, codes should be added*
>         return NULL;
>     }
>     OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
>     if (output_ctx == NULL) {
>        *LogFileFreeCtx(logfile_ctx); //iswalker, codes should be added*
>        return NULL;
>     }
>     output_ctx->data = file_ctx;
>     output_ctx->DeInit = AlertUnifiedLogDeInitCtx;
> 
>     SCLogInfo("Unified-log initialized: filename %s, limit %"PRIu32" MB",
>        filename, limit);
> 
>     return output_ctx;
> }

Fixed up as well, thanks!

-- 
---------------------------------------------
Victor Julien
http://www.inliniac.net/
PGP: http://www.inliniac.net/victorjulien.asc
---------------------------------------------




More information about the Oisf-devel mailing list