]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
smtp: Prevent error messages on packet path
authorJeff Lucovsky <jlucovsky@oisf.net>
Sun, 7 Jul 2024 14:29:00 +0000 (10:29 -0400)
committerVictor Julien <victor@inliniac.net>
Sun, 22 Sep 2024 04:45:33 +0000 (06:45 +0200)
Issue: 7126

This commit abandons the use of StringParseUint32 which generates an
error message of there are non-numeric characters.

The SMTP parser had used this function on the packet path; this commit
uses strtoul instead.

An example of the content causing the error message to be emitted:

    3460 LAST

src/app-layer-smtp.c

index 7000b2ec0df607109e87ab9b6c14737fe5d8c464..03260bfd3ae8f17590646995ecfccff0f1312bd3 100644 (file)
@@ -1004,7 +1004,7 @@ static int SMTPParseCommandBDAT(SMTPState *state, const SMTPLine *line)
         /* decoder event */
         return -1;
     }
-    // copy in temporary null-terminated buffer to call StringParseUint32
+    // copy in temporary null-terminated buffer for conversion
     char strbuf[24];
     int len = 23;
     if (line->len - i < len) {
@@ -1012,7 +1012,7 @@ static int SMTPParseCommandBDAT(SMTPState *state, const SMTPLine *line)
     }
     memcpy(strbuf, line->buf + i, len);
     strbuf[len] = '\0';
-    if (StringParseUint32(&state->bdat_chunk_len, 10, 0, strbuf) < 0) {
+    if (ByteExtractStringUint32(&state->bdat_chunk_len, 10, 0, strbuf) < 0) {
         /* decoder event */
         return -1;
     }