]> source.dussan.org Git - rspamd.git/commitdiff
[CritFix] Fix controller paths normalisation
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 22 Dec 2020 17:23:11 +0000 (17:23 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 22 Dec 2020 17:23:11 +0000 (17:23 +0000)
It fixes errors like 'rspamd_controller_handle_lua_plugin: plugin handler
/plugins/selectors/list_extractorstors has not been found'

src/libserver/http/http_router.c

index 01d47b6125a82ed570df8370ed112c60664d447c..9f36118b27f9c6d4844ecbb8b2c395b8f0ce73e4 100644 (file)
@@ -286,15 +286,20 @@ rspamd_http_router_finish_handler (struct rspamd_http_connection *conn,
 
                /* Search for path */
                if (msg->url != NULL && msg->url->len != 0) {
+                       gchar *pathbuf = NULL;
 
                        http_parser_parse_url (msg->url->str, msg->url->len, TRUE, &u);
 
                        if (u.field_set & (1 << UF_PATH)) {
                                guint unnorm_len;
-                               lookup.begin = msg->url->str + u.field_data[UF_PATH].off;
+
+                               pathbuf = g_malloc (u.field_data[UF_PATH].len);
+                               memcpy (pathbuf, msg->url->str + u.field_data[UF_PATH].off,
+                                               u.field_data[UF_PATH].len);
+                               lookup.begin = pathbuf;
                                lookup.len = u.field_data[UF_PATH].len;
 
-                               rspamd_http_normalize_path_inplace ((gchar *)lookup.begin,
+                               rspamd_http_normalize_path_inplace (pathbuf,
                                                lookup.len,
                                                &unnorm_len);
                                lookup.len = unnorm_len;
@@ -307,6 +312,10 @@ rspamd_http_router_finish_handler (struct rspamd_http_connection *conn,
                        found = g_hash_table_lookup (entry->rt->paths, &lookup);
                        memcpy (&handler, &found, sizeof (found));
                        msg_debug ("requested known path: %T", &lookup);
+
+                       if (pathbuf) {
+                               g_free (pathbuf);
+                       }
                }
                else {
                        err = g_error_new (HTTP_ERROR, 404,