From: Vsevolod Stakhov Date: Thu, 25 Sep 2025 10:48:32 +0000 (+0100) Subject: [Fix] Fix build on 32 bit platforms X-Git-Tag: 3.13.1~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2d0df05e50fb78fc6d420c5fc8f3e125b0fee8e0;p=thirdparty%2Frspamd.git [Fix] Fix build on 32 bit platforms --- diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx index c0a2b90e99..4b1867f658 100644 --- a/src/libserver/html/html.cxx +++ b/src/libserver/html/html.cxx @@ -2214,15 +2214,21 @@ auto html_process_input(struct rspamd_task *task, /* naive parse: look for 'url=' and capture token */ auto p = rspamd_substring_search_caseless(cv.data(), cv.size(), "url=", sizeof("url=") - 1); if (p != -1) { - std::string_view urlv{cv.data() + p + (sizeof("url=") - 1), cv.size() - (p + (sizeof("url=") - 1))}; - /* Trim quotes/spaces and trailing separators */ - while (!urlv.empty() && (g_ascii_isspace(urlv.front()) || urlv.front() == '\'' || urlv.front() == '"')) urlv.remove_prefix(1); - while (!urlv.empty() && (urlv.back() == ';' || urlv.back() == '\'' || urlv.back() == '"' || g_ascii_isspace(urlv.back()))) urlv.remove_suffix(1); - if (!urlv.empty()) { - /* validate and count; do not add to urls set */ - auto maybe_url = html_process_url(pool, urlv); - if (maybe_url) { - hc->features.meta_refresh_urls++; + constexpr auto url_key_len = sizeof("url=") - 1; + /* compute offset as size_type to avoid narrowing on 32-bit */ + auto url_off = static_cast(p) + url_key_len; + if (url_off <= cv.size()) { + std::string_view urlv{cv.data() + url_off, cv.size() - url_off}; + /* Trim quotes/spaces and trailing separators */ + while (!urlv.empty() && (g_ascii_isspace(urlv.front()) || urlv.front() == '\'' || urlv.front() == '"')) urlv.remove_prefix(1); + while (!urlv.empty() && (urlv.back() == ';' || urlv.back() == '\'' || urlv.back() == '"' || g_ascii_isspace(urlv.back()))) urlv.remove_suffix(1); + + if (!urlv.empty()) { + /* validate and count; do not add to urls set */ + auto maybe_url = html_process_url(pool, urlv); + if (maybe_url) { + hc->features.meta_refresh_urls++; + } } } }