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

iswalker mail2cissp at gmail.com
Wed Jan 26 01:43:08 UTC 2011


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 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;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openinfosecfoundation.org/pipermail/oisf-devel/attachments/20110126/b43d6f05/attachment-0002.html>


More information about the Oisf-devel mailing list