]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1981 in SNORT/snort3 from ~MIALTIZE/snort3:f31_const to master
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Mon, 3 Feb 2020 20:10:23 +0000 (20:10 +0000)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Mon, 3 Feb 2020 20:10:23 +0000 (20:10 +0000)
Squashed commit of the following:

commit 1031ff1e1db6a258fb70b5f50f04b24e07d8d2ce
Author: Michael Altizer <mialtize@cisco.com>
Date:   Mon Feb 3 12:48:30 2020 -0500

    build: Updates across the board for stricter Clang const-casting warnings

13 files changed:
src/ips_options/ips_cvs.cc
src/mime/file_mime_log.cc
src/mime/file_mime_process.cc
src/network_inspectors/appid/service_plugins/service_mdns.cc
src/service_inspectors/dce_rpc/dce_smb_commands.cc
src/service_inspectors/ftp_telnet/ftp_splitter.cc
src/service_inspectors/ftp_telnet/pp_ftp.cc
src/service_inspectors/imap/imap.cc
src/service_inspectors/imap/imap_paf.cc
src/service_inspectors/pop/pop.cc
src/service_inspectors/sip/sip_parser.cc
src/service_inspectors/smtp/smtp_util.cc
src/service_inspectors/ssh/ssh.cc

index 3ba9bf9dd7f0be95926b775f2cc1d968de98afa2..39f801890bf4463a2ee2678726b4c00add6635e2 100644 (file)
@@ -332,7 +332,7 @@ static int CvsValidateEntry(const uint8_t* entry_arg, const uint8_t* end_arg)
         }
         if (*entry_arg != '/')
         {
-            entry_arg = (uint8_t*)memchr(entry_arg, '/', end_arg - entry_arg);
+            entry_arg = (const uint8_t*)memchr(entry_arg, '/', end_arg - entry_arg);
             if (entry_arg == nullptr)
                 break;
         }
@@ -359,7 +359,7 @@ static int CvsValidateEntry(const uint8_t* entry_arg, const uint8_t* end_arg)
 static void CvsGetEOL(const uint8_t* ptr, const uint8_t* end,
     const uint8_t** eol, const uint8_t** eolm)
 {
-    *eolm = (uint8_t*)memchr(ptr, CVS_COMMAND_DELIMITER, end - ptr);
+    *eolm = (const uint8_t*)memchr(ptr, CVS_COMMAND_DELIMITER, end - ptr);
     if (*eolm == nullptr)
     {
         *eolm = end;
index e2911fcf8480ef68aca8606d865690e8ef974ef2..ed1889dec91dd1d8b4b330326a9f394eee45da7d 100644 (file)
@@ -133,7 +133,7 @@ int MailLogState::log_email_id(const uint8_t* start, int length, EmailUserType t
     if (length <= 0)
         return -1;
 
-    tmp_eol = (uint8_t*)memchr(start, ':', length);
+    tmp_eol = (const uint8_t*)memchr(start, ':', length);
     if (tmp_eol == nullptr)
         return -1;
 
index e25a82889f3a6e1481771845b1325a861a25a062..228f90a514571700479dc30aa5c7dd850f6a570d 100644 (file)
@@ -91,7 +91,7 @@ static void get_mime_eol(const uint8_t* ptr, const uint8_t* end,
         return;
     }
 
-    tmp_eol = (uint8_t*)memchr(ptr, '\n', end - ptr);
+    tmp_eol = (const uint8_t*)memchr(ptr, '\n', end - ptr);
     if (tmp_eol == nullptr)
     {
         tmp_eol = end;
index f48ae13604cdf543bf958e0d7d7511ee545422ba..44695f782e41ae1458885011f05e3f03e45e974b 100644 (file)
@@ -339,7 +339,7 @@ int MdnsServiceDetector::analyze_user(AppIdSession& asd, const Packet* pkt, uint
                         start_index =0;
 
                     srv_original = resp_endptr  + NEXT_MESSAGE_OFFSET;
-                    user_original = (char*)memchr((const uint8_t*)srv_original, PATTERN_USERNAME_1,
+                    user_original = (const char*)memchr((const uint8_t*)srv_original, PATTERN_USERNAME_1,
                         data_len);
 
                     if (user_original )
index 84e258d77ea9b7832849c59e79e60f8a9b93e968..f2c52c0f2d0b4558d7c3f7b3b2b78e4d3394c313 100644 (file)
@@ -1566,13 +1566,13 @@ DCE2_Ret DCE2_SmbNegotiate(DCE2_SmbSsnData* ssd, const SmbNtHdr*,
     if (DCE2_ComInfoIsRequest(com_info))
     {
         // Have at least 2 bytes based on byte count check done earlier
-        uint8_t* term_ptr;
+        const uint8_t* term_ptr;
         int ntlm_index = 0;
         uint16_t com_size = DCE2_ComInfoCommandSize(com_info);
 
         dce2_move(nb_ptr, nb_len, com_size);
 
-        while ((term_ptr = (uint8_t*)memchr(nb_ptr, '\0', nb_len)) != nullptr)
+        while ((term_ptr = (const uint8_t*)memchr(nb_ptr, '\0', nb_len)) != nullptr)
         {
             if (!SmbFmtDialect(*nb_ptr))
             {
index 10a9dbc8a1b94a82940ee062a3cd8a2bbca94fc4..735b2d9f4e363a633d7ecfeb8aee1c721ca002ef 100644 (file)
@@ -43,7 +43,7 @@ StreamSplitter::Status FtpSplitter::scan(
         return FLUSH;
     }
 #ifdef HAVE_MEMRCHR
-    uint8_t* lf =  (uint8_t*)memrchr(data, '\n', len);
+    const uint8_t* lf =  (const uint8_t*)memrchr(data, '\n', len);
 #else
     uint32_t n = len;
     const uint8_t* lf = nullptr, * tmp = data;
index 2a9aff09ca4bf01eccb1e99e1d0ca4dc001570cc..e59cdaf884d913cbfad3f35c9807b47a6ff025ba 100644 (file)
@@ -1611,7 +1611,7 @@ int check_ftp(FTP_SESSION* ftpssn, Packet* p, int iMode)
                 /* Now grab the command parameters/response message
                  * read_ptr < end already checked */
                 req->param_begin = (const char*)read_ptr;
-                if ((read_ptr = (unsigned char*)memchr(read_ptr, CR, end - read_ptr)) == nullptr)
+                if ((read_ptr = (const unsigned char*)memchr(read_ptr, CR, end - read_ptr)) == nullptr)
                     read_ptr = end;
                 req->param_end = (const char*)read_ptr;
                 req->param_size = req->param_end - req->param_begin;
index 144f65815dbfbe2d87c36847683952593fdd585c..c9959c03e649efc26298fe6ce1d0bd002e7dbb6a 100644 (file)
@@ -234,7 +234,7 @@ static void IMAP_GetEOL(const uint8_t* ptr, const uint8_t* end,
     const uint8_t* tmp_eol;
     const uint8_t* tmp_eolm;
 
-    tmp_eol = (uint8_t*)memchr(ptr, '\n', end - ptr);
+    tmp_eol = (const uint8_t*)memchr(ptr, '\n', end - ptr);
     if (tmp_eol == nullptr)
     {
         tmp_eol = end;
index 8df13d4febd11da9bb32176ea103a4fa5f75afbb..56d97e86c80f589c7acb73f5f003ea9acd12ee2e 100644 (file)
@@ -455,7 +455,7 @@ static StreamSplitter::Status imap_paf_client(const uint8_t* data, uint32_t len,
 {
     const char* pch;
 
-    pch = (char *)memchr (data, '\n', len);
+    pch = (const char *)memchr (data, '\n', len);
 
     if (pch != nullptr)
     {
index c108f731add63c6e0d65e1b7f2b6765d6a1aa8c9..4e8157c1ce1e5fcb99c0b337abd7bf5a482cfad1 100644 (file)
@@ -193,7 +193,7 @@ static void POP_GetEOL(const uint8_t* ptr, const uint8_t* end,
     const uint8_t* tmp_eol;
     const uint8_t* tmp_eolm;
 
-    tmp_eol = (uint8_t*)memchr(ptr, '\n', end - ptr);
+    tmp_eol = (const uint8_t*)memchr(ptr, '\n', end - ptr);
     if (tmp_eol == nullptr)
     {
         tmp_eol = end;
index 0dd7d31aee14cd0d9bbed9a304503c43b820bed4..3b8f996c6b01f1e62776bcecbcae4c8f18eb6b5f 100644 (file)
@@ -141,10 +141,9 @@ SIPbodyField bodyFields[] =
 static int sip_process_headField(SIPMsg* msg, const char* start, const char* end,
     int* lastFieldIndex, SIP_PROTO_CONF* config)
 {
-    int findex =0;
+    int findex = 0;
     int length = end -start;
-    char* colonIndex;
-    const char* newStart, * newEnd;
+    const char* colonIndex, * newStart, * newEnd;
     char newLength;
 
     // If this is folding
@@ -157,7 +156,7 @@ static int sip_process_headField(SIPMsg* msg, const char* start, const char* end
         }
     }
     // Otherwise, continue normal processing
-    colonIndex = (char*)memchr(start, ':', length);
+    colonIndex = (const char*)memchr(start, ':', length);
 
     if (!colonIndex || (colonIndex < start + 1))
         return SIP_PARSE_ERROR;
@@ -165,7 +164,7 @@ static int sip_process_headField(SIPMsg* msg, const char* start, const char* end
     if (!SIP_TrimSP(start, colonIndex, &newStart, &newEnd))
         return SIP_PARSE_ERROR;
 
-    newLength =  newEnd - newStart;
+    newLength = newEnd - newStart;
 
     /*Find out whether the field name needs to process*/
     while (nullptr != headerFields[findex].fname)
@@ -341,9 +340,9 @@ static bool sip_startline_parse(SIPMsg* msg, const char* buff, const char* end,
 
     *lineEnd = next;
     // This is a response
-    if (0 == strncmp((const char*)buff, (const char*)SIP_KEYWORD, SIP_KEYWORD_LEN))
+    if (0 == strncmp(buff, SIP_KEYWORD, SIP_KEYWORD_LEN))
     {
-        char* space;
+        const char* space;
         unsigned long statusCode;
 
         /*Process response*/
@@ -356,7 +355,7 @@ static bool sip_startline_parse(SIPMsg* msg, const char* buff, const char* end,
             DetectionEngine::queue_event(GID_SIP, SIP_EVENT_INVALID_VERSION);
         }
 
-        space = (char*)strchr(buff, ' ');
+        space = strchr(buff, ' ');
         if (space == nullptr)
             return false;
         statusCode = SnortStrtoul(space + 1, nullptr, 10);
@@ -370,15 +369,14 @@ static bool sip_startline_parse(SIPMsg* msg, const char* buff, const char* end,
     }
     else  /* This might be a request*/
     {
-        char* space;
-        char* version;
+        const char* space, * version;
         SIPMethodNode* method;
 
         /*Process request*/
         msg->status_code = 0;
 
         // Parse the method
-        space = (char*)memchr(buff, ' ', end - buff);
+        space = (const char*)memchr(buff, ' ', end - buff);
         if (space == nullptr)
             return false;
         msg->method = buff;
@@ -394,7 +392,7 @@ static bool sip_startline_parse(SIPMsg* msg, const char* buff, const char* end,
         if (space + 1 > end)
             return false;
         msg->uri = space + 1;
-        space = (char*)memchr(space + 1, ' ', end - msg->uri);
+        space = (const char*)memchr(space + 1, ' ', end - msg->uri);
         if (space == nullptr)
             return false;
         msg->uriLen = space - msg->uri;
@@ -407,7 +405,7 @@ static bool sip_startline_parse(SIPMsg* msg, const char* buff, const char* end,
         version = space + 1;
         if (version + SIP_VERSION_LEN > end)
             return false;
-        if (0 != strncmp((const char*)version, (const char*)SIP_KEYWORD, SIP_KEYWORD_LEN))
+        if (0 != strncmp(version, SIP_KEYWORD, SIP_KEYWORD_LEN))
             return false;
         /*Check SIP version number, end with CRLF*/
         if (!sip_is_valid_version(*lineEnd - SIP_VERSION_NUM_LEN - numOfLineBreaks))
@@ -662,9 +660,9 @@ static int sip_parse_via(SIPMsg* msg, const char* start, const char* end, SIP_PR
 
 static int sip_parse_from(SIPMsg* msg, const char* start, const char* end, SIP_PROTO_CONF*)
 {
-    char* buff;
-    char* userEnd;
-    char* userStart;
+    const char* buff;
+    const char* userEnd;
+    const char* userStart;
 
     msg->from = start;
     msg->fromLen = end - start;
@@ -672,7 +670,7 @@ static int sip_parse_from(SIPMsg* msg, const char* start, const char* end, SIP_P
     /*Get the from tag*/
     msg->fromTagLen = 0;
 
-    buff = (char*)memchr(start, ';', msg->fromLen);
+    buff = (const char*)memchr(start, ';', msg->fromLen);
     while ((nullptr != buff)&& (buff < end))
     {
         if (0 == strncmp(buff + 1, SIP_TAG_KEYWORD, SIP_TAG_KEYWORD_LEN))
@@ -682,11 +680,11 @@ static int sip_parse_from(SIPMsg* msg, const char* start, const char* end, SIP_P
             msg->dlgID.fromTagHash = strToHash(msg->from_tag,msg->fromTagLen);
             break;
         }
-        buff = (char*)memchr(buff + 1, ';', msg->fromLen);
+        buff = (const char*)memchr(buff + 1, ';', msg->fromLen);
     }
 
-    userStart = (char*)memchr(msg->from, ':', msg->fromLen);
-    userEnd = (char*)memchr(msg->from, '>', msg->fromLen);
+    userStart = (const char*)memchr(msg->from, ':', msg->fromLen);
+    userEnd = (const char*)memchr(msg->from, '>', msg->fromLen);
 
     if (userStart && userEnd && (userEnd > userStart))
     {
@@ -719,14 +717,14 @@ static int sip_parse_from(SIPMsg* msg, const char* start, const char* end, SIP_P
 
 static int sip_parse_to(SIPMsg* msg, const char* start, const char* end, SIP_PROTO_CONF*)
 {
-    char* buff;
+    const char* buff;
     msg->to = start;
     msg->toLen = end - start;
 
     /*Processing tag information*/
     msg->toTagLen = 0;
 
-    buff = (char*)memchr(start, ';', msg->toLen);
+    buff = (const char*)memchr(start, ';', msg->toLen);
     while ((nullptr != buff)&& (buff < end))
     {
         if (0 == strncmp(buff + 1, SIP_TAG_KEYWORD, SIP_TAG_KEYWORD_LEN))
@@ -736,7 +734,7 @@ static int sip_parse_to(SIPMsg* msg, const char* start, const char* end, SIP_PRO
             msg->dlgID.toTagHash = strToHash(msg->to_tag,msg->toTagLen);
             break;
         }
-        buff = (char*)memchr(buff + 1, ';', msg->toLen);
+        buff = (const char*)memchr(buff + 1, ';', msg->toLen);
     }
 
     return SIP_PARSE_SUCCESS;
@@ -781,7 +779,7 @@ static int sip_parse_call_id(SIPMsg* msg, const char* start, const char* end, SI
     int length = end -start;
     msg->call_id = start;
     /*ignore ip address in call id by adjusting length*/
-    char* at = (char*)memchr(start, '@', length);
+    const char* at = (const char*)memchr(start, '@', length);
     if (at && (at < end) && is_valid_ip(at+1, (end-at-1)))
     {
         length = at - start;
@@ -1017,20 +1015,20 @@ static int sip_parse_content_encode(
 static int sip_parse_sdp_o(SIPMsg* msg, const char* start, const char* end)
 {
     int length;
-    char* spaceIndex = nullptr;
-    char* spaceIndex2 = nullptr;
+    const char* spaceIndex;
+    const char* spaceIndex2;
 
     if (nullptr == msg->mediaSession)
         return SIP_PARSE_ERROR;
     length = end - start;
     // Get username and session ID information (before second space)
-    spaceIndex = (char*)memchr(start, ' ', length);  // first space
+    spaceIndex = (const char*)memchr(start, ' ', length);  // first space
     if ((nullptr == spaceIndex)||(spaceIndex == end))
         return SIP_PARSE_ERROR;
-    spaceIndex = (char*)memchr(spaceIndex + 1, ' ', end - spaceIndex -1);   // second space
+    spaceIndex = (const char*)memchr(spaceIndex + 1, ' ', end - spaceIndex -1);   // second space
     if (nullptr == spaceIndex)
         return SIP_PARSE_ERROR;
-    spaceIndex2 = (char*)memchr(spaceIndex + 1, ' ', end - spaceIndex -1);   // third space
+    spaceIndex2 = (const char*)memchr(spaceIndex + 1, ' ', end - spaceIndex -1);   // third space
     if (nullptr == spaceIndex2)
         return SIP_PARSE_ERROR;
 
@@ -1060,17 +1058,17 @@ static int sip_parse_sdp_c(SIPMsg* msg, const char* start, const char* end)
     SfIp* ip;
     char ipStr[INET6_ADDRSTRLEN + 5];     /* Enough for IPv4 plus netmask or
                                                        full IPv6 plus prefix */
-    char* spaceIndex = nullptr;
+    const char* spaceIndex;
 
     if (nullptr == msg->mediaSession)
         return SIP_PARSE_ERROR;
     length = end - start;
 
     /*Get the IP address*/
-    spaceIndex = (char*)memchr(start, ' ', length);  // first space
+    spaceIndex = (const char*)memchr(start, ' ', length);  // first space
     if ((nullptr == spaceIndex)||(spaceIndex == end))
         return SIP_PARSE_ERROR;
-    spaceIndex = (char*)memchr(spaceIndex + 1, ' ', end - spaceIndex -1);   // second space
+    spaceIndex = (const char*)memchr(spaceIndex + 1, ' ', end - spaceIndex -1);   // second space
     if (nullptr == spaceIndex)
         return SIP_PARSE_ERROR;
     length = end - spaceIndex;
@@ -1116,7 +1114,7 @@ static int sip_parse_sdp_c(SIPMsg* msg, const char* start, const char* end)
 static int sip_parse_sdp_m(SIPMsg* msg, const char* start, const char* end)
 {
     int length;
-    char* spaceIndex = nullptr;
+    const char* spaceIndex;
     char* next;
     SIP_MediaData* mdata;
 
@@ -1124,7 +1122,7 @@ static int sip_parse_sdp_m(SIPMsg* msg, const char* start, const char* end)
         return SIP_PARSE_ERROR;
     length = end - start;
 
-    spaceIndex = (char*)memchr(start, ' ', length);  // first space
+    spaceIndex = (const char*)memchr(start, ' ', length);  // first space
 
     if ((nullptr == spaceIndex)||(spaceIndex == end))
         return SIP_PARSE_ERROR;
index f35a555be8d4c7e4765542317a9b3008002275e4..97ec6254f300cc0e20eb41c1cdf97dc0bb29bb4a 100644 (file)
@@ -41,7 +41,7 @@ void SMTP_GetEOL(const uint8_t* ptr, const uint8_t* end,
     assert(ptr and end and eol and eolm);
 
     const uint8_t* tmp_eolm;
-    const uint8_t* tmp_eol = (uint8_t*)memchr(ptr, '\n', end - ptr);
+    const uint8_t* tmp_eol = (const uint8_t*)memchr(ptr, '\n', end - ptr);
 
     if (tmp_eol == nullptr)
     {
index b258e740e8d4e64b31aae9ade0b2842cb584f2ad..0920e9a58cf5f7f060129a023b9d9f9d22beb787 100644 (file)
@@ -376,7 +376,7 @@ static unsigned int ProcessSSHProtocolVersionExchange(SSH_PROTO_CONF* config, SS
         break;
     }
 
-    version_end = (char*)memchr(version_stringp, '\n', p->dsize);
+    version_end = (const char*)memchr(version_stringp, '\n', p->dsize);
     if (version_end)
         return ((version_end - version_stringp) + 1);
     /* incomplete version string, should end with \n or \r\n for sshv2 */