]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #3060 in SNORT/snort3 from ~KATHARVE/snort3:portablility to master
authorTom Peters (thopeter) <thopeter@cisco.com>
Fri, 17 Sep 2021 20:23:12 +0000 (20:23 +0000)
committerTom Peters (thopeter) <thopeter@cisco.com>
Fri, 17 Sep 2021 20:23:12 +0000 (20:23 +0000)
Squashed commit of the following:

commit 334e79aa67c4494c0f4c3814ca9eb1897b7cc7a1
Author: Katura Harvey <katharve@cisco.com>
Date:   Wed Sep 15 12:42:01 2021 -0400

    http_inspect: remove memrchr for portability

src/service_inspectors/http_inspect/http_msg_body.cc

index 63cd4d27795a068836864211aaadd131d56d0636..8443da2b63f2338180be8e4c89897563aa1cc3f1 100644 (file)
@@ -490,12 +490,18 @@ void HttpMsgBody::get_file_info(FileDirection dir, const uint8_t*& filename_buff
         const Field& path = http_uri->get_norm_path(); 
         if (path.length() > 0)
         {
-            const uint8_t* last_slash = (const uint8_t*)memrchr(path.start(), '/', path.length());
-            if (last_slash)
+            int last_slash_index = path.length() - 1;
+            while (last_slash_index >= 0)
             {
-                filename_length = (path.start() + path.length()) - (last_slash + 1);
+                if (path.start()[last_slash_index] == '/')
+                    break;
+                last_slash_index--;
+            }
+            if (last_slash_index >= 0)
+            {
+                filename_length = (path.length() - (last_slash_index + 1));
                 if (filename_length > 0)
-                    filename_buffer = last_slash + 1;
+                    filename_buffer = path.start() + last_slash_index + 1;
             }
         }
     }