]> source.dussan.org Git - rspamd.git/commitdiff
Try to fix crashes when GString is reallocated.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 24 Sep 2015 14:21:35 +0000 (15:21 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 24 Sep 2015 14:21:35 +0000 (15:21 +0100)
Issue: #381

src/libutil/http.c

index d15633f8ed339c998c5304960befefdb456473f2..4405e3fc52b37291f25588a0b1ab42fd3a29a808 100644 (file)
@@ -1913,9 +1913,16 @@ rspamd_http_router_try_file (struct rspamd_http_connection_entry *entry,
 
        if (S_ISDIR (st.st_mode) && expand_path) {
                /* Try to append 'index.html' to the url */
-               g_string_append_printf (lookup, "%c%s", G_DIR_SEPARATOR,
-                       "index.html");
-               return rspamd_http_router_try_file (entry, lookup, FALSE);
+               GString *nlookup;
+               gboolean ret;
+
+               nlookup = g_string_sized_new (lookup->len + sizeof ("index.html") + 1);
+               rspamd_printf_gstring (nlookup, "%v%c%s", lookup, G_DIR_SEPARATOR,
+                               "index.html");
+               ret = rspamd_http_router_try_file (entry, nlookup, FALSE);
+               g_string_free (nlookup, TRUE);
+
+               return ret;
        }
        else if (!S_ISREG (st.st_mode)) {
                return FALSE;