From: Victor Julien Date: Fri, 21 Oct 2022 09:38:36 +0000 (+0200) Subject: smtp/mime: no error logging in packet path X-Git-Tag: suricata-7.0.0-beta1~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d3c60bde361bb1e9dc2eba0e6d168b0b84d7f3f;p=thirdparty%2Fsuricata.git smtp/mime: no error logging in packet path --- diff --git a/src/app-layer-smtp.c b/src/app-layer-smtp.c index f30c372a99..b4230d2cb7 100644 --- a/src/app-layer-smtp.c +++ b/src/app-layer-smtp.c @@ -1182,8 +1182,6 @@ static int SMTPProcessRequest(SMTPState *state, Flow *f, AppLayerParserState *ps } tx->mime_state = MimeDecInitParser(f, SMTPProcessDataChunk); if (tx->mime_state == NULL) { - SCLogError(SC_ERR_MEM_ALLOC, "MimeDecInitParser() failed to " - "allocate data"); return MIME_DEC_ERR_MEM; } diff --git a/src/util-decode-mime.c b/src/util-decode-mime.c index c9eb26570c..6cf1dd5020 100644 --- a/src/util-decode-mime.c +++ b/src/util-decode-mime.c @@ -273,7 +273,6 @@ MimeDecField * MimeDecAddField(MimeDecEntity *entity) { MimeDecField *node = SCMalloc(sizeof(MimeDecField)); if (unlikely(node == NULL)) { - SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed"); return NULL; } memset(node, 0x00, sizeof(MimeDecField)); @@ -359,7 +358,6 @@ static MimeDecUrl * MimeDecAddUrl(MimeDecEntity *entity, uint8_t *url, uint32_t { MimeDecUrl *node = SCMalloc(sizeof(MimeDecUrl)); if (unlikely(node == NULL)) { - SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed"); return NULL; } memset(node, 0x00, sizeof(MimeDecUrl)); @@ -393,7 +391,6 @@ MimeDecEntity * MimeDecAddEntity(MimeDecEntity *parent) { MimeDecEntity *curr, *node = SCMalloc(sizeof(MimeDecEntity)); if (unlikely(node == NULL)) { - SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed"); return NULL; } memset(node, 0x00, sizeof(MimeDecEntity)); @@ -469,7 +466,6 @@ static MimeDecStackNode * PushStack(MimeDecStack *stack) if (node == NULL) { node = SCMalloc(sizeof(MimeDecStackNode)); if (unlikely(node == NULL)) { - SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed"); return NULL; } } else { @@ -567,7 +563,6 @@ static DataValue * AddDataValue(DataValue *dv) { DataValue *curr, *node = SCMalloc(sizeof(DataValue)); if (unlikely(node == NULL)) { - SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed"); return NULL; } memset(node, 0x00, sizeof(DataValue)); @@ -632,7 +627,6 @@ static uint8_t *GetFullValue(const DataValue *dv, uint32_t *olen) if (len > 0) { val = SCCalloc(1, len); if (unlikely(val == NULL)) { - SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed"); return NULL; } for (const DataValue *curr = dv; curr != NULL; curr = curr->next) { @@ -809,9 +803,8 @@ static int StoreMimeHeader(MimeDecParseState *state) ret = MIME_DEC_ERR_PARSE; } else if (state->stack->top != NULL) { /* Store each header name and value */ - if (MimeDecFillField(state->stack->top->data, state->hname, - state->hlen, val, vlen) == NULL) { - SCLogError(SC_ERR_MEM_ALLOC, "MimeDecFillField() function failed"); + if (MimeDecFillField(state->stack->top->data, state->hname, state->hlen, val, + vlen) == NULL) { ret = MIME_DEC_ERR_MEM; } else { stored = 1; @@ -822,7 +815,6 @@ static int StoreMimeHeader(MimeDecParseState *state) } } else if (state->hvalue != NULL) { /* Memory allocation must have failed since val is NULL */ - SCLogError(SC_ERR_MEM_ALLOC, "GetFullValue() function failed"); ret = MIME_DEC_ERR_MEM; } @@ -1030,7 +1022,6 @@ static int FindUrlStrings(const uint8_t *line, uint32_t len, /* First copy to temp URL string */ tempUrl = SCMalloc(tokLen); if (unlikely(tempUrl == NULL)) { - SCLogError(SC_ERR_MEM_ALLOC, "Memory allocation failed"); return MIME_DEC_ERR_MEM; } @@ -1745,7 +1736,6 @@ static int FindMimeHeader(const uint8_t *buf, uint32_t blen, if (vlen > 0) { dv = AddDataValue(state->hvalue); if (dv == NULL) { - SCLogError(SC_ERR_MEM_ALLOC, "AddDataValue() function failed"); return MIME_DEC_ERR_MEM; } if (state->hvalue == NULL) { @@ -1754,7 +1744,6 @@ static int FindMimeHeader(const uint8_t *buf, uint32_t blen, dv->value = SCMalloc(vlen); if (unlikely(dv->value == NULL)) { - SCLogError(SC_ERR_MEM_ALLOC, "Memory allocation failed"); return MIME_DEC_ERR_MEM; } memcpy(dv->value, buf, vlen); @@ -1793,7 +1782,6 @@ static int FindMimeHeader(const uint8_t *buf, uint32_t blen, /* Copy name and value to state */ state->hname = SCMalloc(hlen); if (unlikely(state->hname == NULL)) { - SCLogError(SC_ERR_MEM_ALLOC, "Memory allocation failed"); return MIME_DEC_ERR_MEM; } memcpy(state->hname, hname, hlen); @@ -1819,12 +1807,10 @@ static int FindMimeHeader(const uint8_t *buf, uint32_t blen, if (vlen > 0) { state->hvalue = AddDataValue(NULL); if (state->hvalue == NULL) { - SCLogError(SC_ERR_MEM_ALLOC, "AddDataValue() function failed"); return MIME_DEC_ERR_MEM; } state->hvalue->value = SCMalloc(vlen); if (unlikely(state->hvalue->value == NULL)) { - SCLogError(SC_ERR_MEM_ALLOC, "Memory allocation failed"); return MIME_DEC_ERR_MEM; } memcpy(state->hvalue->value, hval, vlen); @@ -1899,7 +1885,6 @@ static int ProcessMimeHeaders(const uint8_t *buf, uint32_t len, /* Copy over using dynamic memory */ entity->filename = SCMalloc(blen); if (unlikely(entity->filename == NULL)) { - SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed"); return MIME_DEC_ERR_MEM; } memcpy(entity->filename, bptr, blen); @@ -1930,7 +1915,6 @@ static int ProcessMimeHeaders(const uint8_t *buf, uint32_t len, /* Store boundary in parent node */ state->stack->top->bdef = SCMalloc(blen); if (unlikely(state->stack->top->bdef == NULL)) { - SCLogError(SC_ERR_MEM_ALLOC, "Memory allocation failed"); return MIME_DEC_ERR_MEM; } memcpy(state->stack->top->bdef, bptr, blen); @@ -1953,7 +1937,6 @@ static int ProcessMimeHeaders(const uint8_t *buf, uint32_t len, /* Copy over using dynamic memory */ entity->filename = SCMalloc(blen); if (unlikely(entity->filename == NULL)) { - SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed"); return MIME_DEC_ERR_MEM; } memcpy(entity->filename, bptr, blen); @@ -2413,14 +2396,12 @@ MimeDecParseState * MimeDecInitParser(void *data, state = SCMalloc(sizeof(MimeDecParseState)); if (unlikely(state == NULL)) { - SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed"); return NULL; } memset(state, 0x00, sizeof(MimeDecParseState)); state->stack = SCMalloc(sizeof(MimeDecStack)); if (unlikely(state->stack == NULL)) { - SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed"); SCFree(state); return NULL; } @@ -2428,7 +2409,6 @@ MimeDecParseState * MimeDecInitParser(void *data, mimeMsg = SCMalloc(sizeof(MimeDecEntity)); if (unlikely(mimeMsg == NULL)) { - SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed"); SCFree(state->stack); SCFree(state); return NULL; @@ -2440,7 +2420,6 @@ MimeDecParseState * MimeDecInitParser(void *data, state->msg = mimeMsg; PushStack(state->stack); if (state->stack->top == NULL) { - SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed"); SCFree(state->stack); SCFree(state); return NULL;