]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
mime: remove unused 'linerem' logic
authorVictor Julien <vjulien@oisf.net>
Sun, 26 Jun 2022 14:25:36 +0000 (16:25 +0200)
committerVictor Julien <vjulien@oisf.net>
Wed, 29 Jun 2022 20:57:29 +0000 (22:57 +0200)
(cherry picked from commit 0871029d17d23a7875af074d76965675c31599f0)

src/util-decode-mime.c
src/util-decode-mime.h

index 150fac9957be8f630bfa7472ce1513691f2bf954..12be127e455b49b87ce7d767e3cea7de35d561e3 100644 (file)
@@ -1140,38 +1140,31 @@ static int ProcessDecodedDataChunk(const uint8_t *chunk, uint32_t len,
                 (entity->ctnt_flags & CTNT_IS_HTML)) &&
                 ((entity->ctnt_flags & CTNT_IS_ATTACHMENT) == 0)) {
 
-                /* Remainder from previous line */
-                if (state->linerem_len > 0) {
-                    // TODO
-                } else {
-                    /* No remainder from previous line */
-                    /* Parse each line one by one */
-                    remainPtr = (uint8_t *)chunk;
-                    do {
-                        tok = GetLine(remainPtr, len - (remainPtr - (uint8_t *)chunk),
-                                &remainPtr, &tokLen);
-                        if (tok != remainPtr) {
-                            // DEBUG - ADDED
-                            /* If last token found without CR/LF delimiter, then save
-                             * and reconstruct with next chunk
-                             */
-                            if (tok + tokLen - (uint8_t *) chunk == (int)len) {
-                                PrintChars(SC_LOG_DEBUG, "LAST CHUNK LINE - CUTOFF",
-                                        tok, tokLen);
-                                SCLogDebug("\nCHUNK CUTOFF CHARS: %u delim %u\n",
-                                        tokLen, len - (uint32_t)(tok + tokLen - (uint8_t *) chunk));
-                            } else {
-                                /* Search line for URL */
-                                ret = FindUrlStrings(tok, tokLen, state);
-                                if (ret != MIME_DEC_OK) {
-                                    SCLogDebug("Error: FindUrlStrings() function"
-                                            " failed: %d", ret);
-                                    break;
-                                }
+                /* Parse each line one by one */
+                remainPtr = (uint8_t *)chunk;
+                do {
+                    tok = GetLine(remainPtr, len - (remainPtr - (uint8_t *)chunk),
+                            &remainPtr, &tokLen);
+                    if (tok != remainPtr) {
+                        /* If last token found without CR/LF delimiter, then save
+                         * and reconstruct with next chunk
+                         */
+                        if (tok + tokLen - (uint8_t *) chunk == (int)len) {
+                            PrintChars(SC_LOG_DEBUG, "LAST CHUNK LINE - CUTOFF",
+                                    tok, tokLen);
+                            SCLogDebug("\nCHUNK CUTOFF CHARS: %u delim %u\n",
+                                    tokLen, len - (uint32_t)(tok + tokLen - (uint8_t *) chunk));
+                        } else {
+                            /* Search line for URL */
+                            ret = FindUrlStrings(tok, tokLen, state);
+                            if (ret != MIME_DEC_OK) {
+                                SCLogDebug("Error: FindUrlStrings() function"
+                                        " failed: %d", ret);
+                                break;
                             }
                         }
-                    } while (tok != remainPtr && remainPtr - (uint8_t *) chunk < (int)len);
-                }
+                    }
+                } while (tok != remainPtr && remainPtr - (uint8_t *) chunk < (int)len);
             }
         }
 
index 80bb96c23450f8c8a23c1ff3e971aa11254074e0..2b42f19a65c5931e238501e76ec888071fcbe764 100644 (file)
@@ -64,7 +64,6 @@
 
 /* Publicly exposed size constants */
 #define DATA_CHUNK_SIZE  3072  /* Should be divisible by 3 */
-#define LINEREM_SIZE      256
 
 /* Mime Parser Constants */
 #define HEADER_READY    0x01
@@ -192,8 +191,6 @@ typedef struct MimeDecParseState {
     uint32_t hlen;  /**< Length of the last known header name */
     uint32_t hvlen; /**< Total length of value list */
     DataValue *hvalue;  /**< Pointer to the incomplete header value list */
-    uint8_t linerem[LINEREM_SIZE];  /**< Remainder from previous line (for URL extraction) */
-    uint16_t linerem_len;  /**< Length of remainder from previous line */
     uint8_t bvremain[B64_BLOCK];  /**< Remainder from base64-decoded line */
     uint8_t bvr_len;  /**< Length of remainder from base64-decoded line */
     uint8_t data_chunk[DATA_CHUNK_SIZE];  /**< Buffer holding data chunk */