Project

General

Profile

Actions

Bug #6745

closed

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

Added by Alexey Simakov 10 months ago. Updated 9 months 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
Actions #1

Updated by Alexey Simakov 9 months ago

  • Status changed from New to In Review
Actions #2

Updated by Victor Julien 9 months ago

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

Updated by OISF Ticketbot 9 months ago

  • Subtask #6783 added
Actions #4

Updated by OISF Ticketbot 9 months ago

  • Label deleted (Needs backport to 6.0)
Actions #5

Updated by OISF Ticketbot 9 months ago

  • Subtask #6784 added
Actions #6

Updated by OISF Ticketbot 9 months ago

  • Label deleted (Needs backport to 7.0)
Actions #7

Updated by Victor Julien 9 months ago

  • Status changed from In Review to Resolved
Actions #8

Updated by Philippe Antoine 9 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF