Project

General

Profile

Actions

Bug #6745

closed
AS AS

util/mime: Memory leak at util-decode-mime.c:MimeDecInitParser

Bug #6745: util/mime: Memory leak at util-decode-mime.c:MimeDecInitParser

Added by Alexey Simakov about 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Target version:
Affected Versions:
Effort:
low
Difficulty:
low
Label:

Description

Memory allocated at util-decode-mime.c:2422 for mimeMsg structure, could be lost if state->stack->top == NULL ,
condition is true, since there is no corresponding free call for this case

MimeDecParseState * MimeDecInitParser(void *data,
        int (*DataChunkProcessorFunc)(const uint8_t *chunk, uint32_t len,
                MimeDecParseState *state))
{
    MimeDecParseState *state;
    MimeDecEntity *mimeMsg;

    state = SCCalloc(1, sizeof(MimeDecParseState));
    if (unlikely(state == NULL)) {
        return NULL;
    }

    state->stack = SCCalloc(1, sizeof(MimeDecStack));
    if (unlikely(state->stack == NULL)) {
        SCFree(state);
        return NULL;
    }

    mimeMsg = SCCalloc(1, sizeof(MimeDecEntity));
    if (unlikely(mimeMsg == NULL)) {
        SCFree(state->stack);
        SCFree(state);
        return NULL;
    }
    mimeMsg->ctnt_flags |= CTNT_IS_MSG;

    /* Init state */
    state->msg = mimeMsg;
    PushStack(state->stack);
    if (state->stack->top == NULL) {
        SCFree(state->stack);
        SCFree(state);
        return NULL;
    }
    state->stack->top->data = mimeMsg;
    state->state_flag = HEADER_READY;
    state->data = data;
    state->DataChunkProcessorFunc = DataChunkProcessorFunc;

    return state;
}

Subtasks 2 (0 open2 closed)

Bug #6783: util/mime: Memory leak at util-decode-mime.c:MimeDecInitParser (6.0.x backport)ClosedVictor JulienActions
Bug #6784: util/mime: Memory leak at util-decode-mime.c:MimeDecInitParser (7.0.x backport)ClosedVictor JulienActions

AS Updated by Alexey Simakov about 2 years ago Actions #1

  • Status changed from New to In Review

VJ Updated by Victor Julien about 2 years ago Actions #2

  • Target version changed from 7.0.4 to 8.0.0-beta1
  • Label Needs backport to 6.0, Needs backport to 7.0 added

OT Updated by OISF Ticketbot about 2 years ago Actions #3

  • Subtask #6783 added

OT Updated by OISF Ticketbot about 2 years ago Actions #4

  • Label deleted (Needs backport to 6.0)

OT Updated by OISF Ticketbot about 2 years ago Actions #5

  • Subtask #6784 added

OT Updated by OISF Ticketbot about 2 years ago Actions #6

  • Label deleted (Needs backport to 7.0)

VJ Updated by Victor Julien about 2 years ago Actions #7

  • Status changed from In Review to Resolved

PA Updated by Philippe Antoine about 2 years ago Actions #8

  • Status changed from Resolved to Closed
Actions

Also available in: PDF Atom