]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix rfind usage
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 5 Oct 2021 14:48:29 +0000 (15:48 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 5 Oct 2021 14:48:29 +0000 (15:48 +0100)
src/libmime/received.cxx

index 5a04c812b36d383d3ec1a89e089115a3aaf719cc..a39844f1306f774f925ecb8ca5dfe9c77065c159 100644 (file)
@@ -489,9 +489,9 @@ received_process_host_tcpinfo(struct rspamd_task *task,
                        auto obrace_pos = in.find('[');
 
                        if (obrace_pos != std::string_view::npos) {
-                               auto ebrace_pos = in.rfind(']', obrace_pos);
+                               auto ebrace_pos = in.rfind(']');
 
-                               if (ebrace_pos != std::string_view::npos) {
+                               if (ebrace_pos != std::string_view::npos && ebrace_pos > obrace_pos) {
                                        auto substr_addr = in.substr(obrace_pos + 1,
                                                        ebrace_pos - obrace_pos - 1);
                                        addr = rspamd_parse_inet_address_pool(substr_addr.data(),