From: Tom Peters (thopeter) Date: Fri, 17 Sep 2021 20:23:12 +0000 (+0000) Subject: Merge pull request #3060 in SNORT/snort3 from ~KATHARVE/snort3:portablility to master X-Git-Tag: 3.1.13.0~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2625830ba510ec2430941dc960d964a9bcbd441e;p=thirdparty%2Fsnort3.git Merge pull request #3060 in SNORT/snort3 from ~KATHARVE/snort3:portablility to master Squashed commit of the following: commit 334e79aa67c4494c0f4c3814ca9eb1897b7cc7a1 Author: Katura Harvey Date: Wed Sep 15 12:42:01 2021 -0400 http_inspect: remove memrchr for portability --- diff --git a/src/service_inspectors/http_inspect/http_msg_body.cc b/src/service_inspectors/http_inspect/http_msg_body.cc index 63cd4d277..8443da2b6 100644 --- a/src/service_inspectors/http_inspect/http_msg_body.cc +++ b/src/service_inspectors/http_inspect/http_msg_body.cc @@ -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; } } }