From: Aaron Bungay Date: Mon, 1 Mar 2021 02:41:13 +0000 (+0000) Subject: src: use bool instead of int X-Git-Tag: suricata-7.0.0-beta1~953 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5d3a1f92caf1b8fe5db3614ecc898c0e48d34be;p=thirdparty%2Fsuricata.git src: use bool instead of int --- diff --git a/src/app-layer-smtp.c b/src/app-layer-smtp.c index 8389d1812c..2ef8eea6c0 100644 --- a/src/app-layer-smtp.c +++ b/src/app-layer-smtp.c @@ -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); diff --git a/src/app-layer-smtp.h b/src/app-layer-smtp.h index d86e4da62e..14ee51091d 100644 --- a/src/app-layer-smtp.h +++ b/src/app-layer-smtp.h @@ -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; diff --git a/src/util-decode-mime.c b/src/util-decode-mime.c index bb3d6d5814..bb65abd365 100644 --- a/src/util-decode-mime.c +++ b/src/util-decode-mime.c @@ -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, diff --git a/src/util-decode-mime.h b/src/util-decode-mime.h index 99b5b404b8..92afbfbf18 100644 --- a/src/util-decode-mime.h +++ b/src/util-decode-mime.h @@ -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;