]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Default map URL path to "/" when no path component is present
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 28 Mar 2026 09:14:15 +0000 (09:14 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 28 Mar 2026 09:14:15 +0000 (09:14 +0000)
When an HTTP(S) map URL has no path (e.g. "https://maps.rspamd.com"),
the URL parser leaves hdata->path as NULL. This causes a segfault in
write_http_request() which calls strlen() on the NULL path pointer.

Default path to "/" and rest to "" when UF_PATH is not set, matching
standard HTTP semantics.

Fixes: #5955
src/libserver/maps/map.c

index 81062d9c76871b2ea7128bda8e57cbbc786fc602..c8d1c1e9b038b24cc462fda941ef2917e85c6acd 100644 (file)
@@ -3337,6 +3337,11 @@ rspamd_map_parse_backend(struct rspamd_config *cfg, const char *map_line)
                                        hdata->rest = g_strdup("");
                                }
                        }
+                       else {
+                               /* No path in URL (e.g. https://host), default to "/" */
+                               hdata->path = g_strdup("/");
+                               hdata->rest = g_strdup("");
+                       }
 
                        if (up.field_set & (1u << UF_USERINFO)) {
                                /* Create authorisation header for basic auth */