]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
src: use bool instead of int 6907/head
authorAaron Bungay <amb240h@gmail.com>
Mon, 1 Mar 2021 02:41:13 +0000 (02:41 +0000)
committerVictor Julien <vjulien@oisf.net>
Mon, 31 Jan 2022 12:20:51 +0000 (13:20 +0100)
src/app-layer-smtp.c
src/app-layer-smtp.h
src/util-decode-mime.c
src/util-decode-mime.h

index 8389d1812c85f149f80f6b1853d32b363a937caf..2ef8eea6c01109a8390edd6e529dacfc92c7de71 100644 (file)
@@ -65,7 +65,7 @@
 #define FILEDATA_CONTENT_INSPECT_WINDOW 4096
 
 /* raw extraction default value */
-#define SMTP_RAW_EXTRACTION_DEFAULT_VALUE 0
+#define SMTP_RAW_EXTRACTION_DEFAULT_VALUE      false
 #define SMTP_MAX_REQUEST_AND_REPLY_LINE_LENGTH 510
 
 #define SMTP_COMMAND_BUFFER_STEPS 5
@@ -237,7 +237,7 @@ SCEnumCharMap smtp_reply_map[ ] = {
 };
 
 /* Create SMTP config structure */
-SMTPConfig smtp_config = { 0, { 0, 0, 0, NULL, false, 0, 0 }, 0, 0, 0, 0,
+SMTPConfig smtp_config = { false, { false, false, false, NULL, false, false, 0 }, 0, 0, 0, false,
     STREAMING_BUFFER_CONFIG_INITIALIZER };
 
 static SMTPString *SMTPStringAlloc(void);
@@ -396,7 +396,7 @@ static void SMTPConfigure(void) {
     smtp_config.sbcfg.buf_size = content_limit ? content_limit : 256;
 
     if (ConfGetBool("app-layer.protocols.smtp.raw-extraction",
-            &smtp_config.raw_extraction) != 1) {
+                (int *)&smtp_config.raw_extraction) != 1) {
         smtp_config.raw_extraction = SMTP_RAW_EXTRACTION_DEFAULT_VALUE;
     }
     if (smtp_config.raw_extraction && smtp_config.decode_mime) {
@@ -4201,9 +4201,9 @@ static int SMTPParserTest14(void)
     }
 
     /* Enable mime decoding */
-    smtp_config.decode_mime = 1;
-    smtp_config.mime_config.decode_base64 = 1;
-    smtp_config.mime_config.decode_quoted_printable = 1;
+    smtp_config.decode_mime = true;
+    smtp_config.mime_config.decode_base64 = true;
+    smtp_config.mime_config.decode_quoted_printable = true;
     MimeDecSetConfig(&smtp_config.mime_config);
 
     FLOWLOCK_WRLOCK(&f);
index d86e4da62ec7df3845a18bc19d391c1dfc898c7a..14ee51091d52a38080327de613d68aa80821aca9 100644 (file)
@@ -90,13 +90,13 @@ typedef struct SMTPTransaction_ {
 
 typedef struct SMTPConfig {
 
-    int decode_mime;
+    bool decode_mime;
     MimeDecConfig mime_config;
     uint32_t content_limit;
     uint32_t content_inspect_min_size;
     uint32_t content_inspect_window;
 
-    int raw_extraction;
+    bool raw_extraction;
 
     StreamingBufferConfig sbcfg;
 } SMTPConfig;
index bb3d6d5814b173f674ce0d912881ae62ae5859f3..bb65abd365d4400a3a1c9a7f6c8dacc67755808d 100644 (file)
@@ -79,7 +79,7 @@
 #define MAX_IP6_CHARS  39
 
 /* Globally hold configuration data */
-static MimeDecConfig mime_dec_config = { 1, 1, 1, NULL, false, 0, MAX_HEADER_VALUE };
+static MimeDecConfig mime_dec_config = { true, true, true, NULL, false, false, MAX_HEADER_VALUE };
 
 /* Mime Parser String translation */
 static const char *StateFlags[] = { "NONE",
@@ -2758,9 +2758,9 @@ static int MimeDecParseLineTest02(void)
     FAIL_IF_NULL(scheme->val);
     TAILQ_INSERT_TAIL(&url_schemes->head, scheme, next);
 
-    MimeDecGetConfig()->decode_base64 = 1;
-    MimeDecGetConfig()->decode_quoted_printable = 1;
-    MimeDecGetConfig()->extract_urls = 1;
+    MimeDecGetConfig()->decode_base64 = true;
+    MimeDecGetConfig()->decode_quoted_printable = true;
+    MimeDecGetConfig()->extract_urls = true;
     MimeDecGetConfig()->extract_urls_schemes = url_schemes;
 
     /* Init parser */
@@ -2827,7 +2827,7 @@ static int MimeFindUrlStringsTest01(void)
     int ret = MIME_DEC_OK;
     uint32_t line_count = 0;
 
-    MimeDecGetConfig()->extract_urls = 1;
+    MimeDecGetConfig()->extract_urls = true;
     MimeDecGetConfig()->extract_urls_schemes = NULL;
     MimeDecGetConfig()->log_url_scheme = false;
 
@@ -2867,7 +2867,7 @@ static int MimeFindUrlStringsTest02(void)
     FAIL_IF_NULL(scheme->val);
     TAILQ_INSERT_TAIL(&url_schemes->head, scheme, next);
 
-    MimeDecGetConfig()->extract_urls = 1;
+    MimeDecGetConfig()->extract_urls = true;
     MimeDecGetConfig()->extract_urls_schemes = url_schemes;
     MimeDecGetConfig()->log_url_scheme = false;
 
@@ -2923,7 +2923,7 @@ static int MimeFindUrlStringsTest03(void)
     FAIL_IF_NULL(scheme2->val);
     TAILQ_INSERT_TAIL(&url_schemes->head, scheme2, next);
 
-    MimeDecGetConfig()->extract_urls = 1;
+    MimeDecGetConfig()->extract_urls = true;
     MimeDecGetConfig()->extract_urls_schemes = url_schemes;
     MimeDecGetConfig()->log_url_scheme = false;
 
@@ -2987,7 +2987,7 @@ static int MimeFindUrlStringsTest04(void)
     FAIL_IF_NULL(scheme2->val);
     TAILQ_INSERT_TAIL(&url_schemes->head, scheme2, next);
 
-    MimeDecGetConfig()->extract_urls = 1;
+    MimeDecGetConfig()->extract_urls = true;
     MimeDecGetConfig()->extract_urls_schemes = url_schemes;
     MimeDecGetConfig()->log_url_scheme = true;
 
@@ -3046,7 +3046,7 @@ static int MimeFindUrlStringsTest05(void)
     FAIL_IF_NULL(scheme->val);
     TAILQ_INSERT_TAIL(&url_schemes->head, scheme, next);
 
-    MimeDecGetConfig()->extract_urls = 1;
+    MimeDecGetConfig()->extract_urls = true;
     MimeDecGetConfig()->extract_urls_schemes = url_schemes;
     MimeDecGetConfig()->log_url_scheme = true;
 
@@ -3270,9 +3270,9 @@ static int MimeDecParseLongFilename01(void)
 
     uint32_t line_count = 0;
 
-    MimeDecGetConfig()->decode_base64 = 1;
-    MimeDecGetConfig()->decode_quoted_printable = 1;
-    MimeDecGetConfig()->extract_urls = 1;
+    MimeDecGetConfig()->decode_base64 = true;
+    MimeDecGetConfig()->decode_quoted_printable = true;
+    MimeDecGetConfig()->extract_urls = true;
 
     /* Init parser */
     MimeDecParseState *state = MimeDecInitParser(&line_count,
@@ -3334,9 +3334,9 @@ static int MimeDecParseLongFilename02(void)
 
     uint32_t line_count = 0;
 
-    MimeDecGetConfig()->decode_base64 = 1;
-    MimeDecGetConfig()->decode_quoted_printable = 1;
-    MimeDecGetConfig()->extract_urls = 1;
+    MimeDecGetConfig()->decode_base64 = true;
+    MimeDecGetConfig()->decode_quoted_printable = true;
+    MimeDecGetConfig()->extract_urls = true;
 
     /* Init parser */
     MimeDecParseState *state = MimeDecInitParser(&line_count,
index 99b5b404b81845447bcec0a41c0b65e4babb23a5..92afbfbf18a432dded51dfc30aebc29cf1b2530a 100644 (file)
@@ -94,13 +94,13 @@ typedef enum MimeDecRetCode {
  *
  */
 typedef struct MimeDecConfig {
-    int decode_base64;  /**< Decode base64 bodies */
-    int decode_quoted_printable;  /**< Decode quoted-printable bodies */
-    int extract_urls;  /**< Extract and store URLs in data structure */
+    bool decode_base64;             /**< Decode base64 bodies */
+    bool decode_quoted_printable;   /**< Decode quoted-printable bodies */
+    bool extract_urls;              /**< Extract and store URLs in data structure */
     ConfNode *extract_urls_schemes; /**< List of schemes of which to
                                          extract urls  */
     bool log_url_scheme;            /**< Log the scheme of extracted URLs */
-    int body_md5;  /**< Compute md5 sum of body */
+    bool body_md5;                  /**< Compute md5 sum of body */
     uint32_t header_value_depth;  /**< Depth of which to store header values
                                        (Default is 2000) */
 } MimeDecConfig;
@@ -161,7 +161,7 @@ typedef struct MimeDecStackNode {
     MimeDecEntity *data;  /**< Pointer to the entity data structure */
     uint8_t *bdef;  /**< Copy of boundary definition for child entity */
     uint32_t bdef_len;  /**< Boundary length for child entity */
-    int is_encap;  /**< Flag indicating entity is encapsulated in message */
+    bool is_encap;      /**< Flag indicating entity is encapsulated in message */
     struct MimeDecStackNode *next;  /**< Pointer to next item on the stack */
 } MimeDecStackNode;