From 8d9bd52f88cfbe82d7f5e10d0b86b9c2830a939b Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 24 Sep 2015 15:21:35 +0100 Subject: [PATCH] Try to fix crashes when GString is reallocated. Issue: #381 --- src/libutil/http.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/libutil/http.c b/src/libutil/http.c index d15633f8e..4405e3fc5 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -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; -- 2.39.5