From: Vsevolod Stakhov Date: Thu, 24 Sep 2015 14:21:35 +0000 (+0100) Subject: Try to fix crashes when GString is reallocated. X-Git-Tag: 1.0.3~34 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8d9bd52f88cfbe82d7f5e10d0b86b9c2830a939b;p=rspamd.git Try to fix crashes when GString is reallocated. Issue: #381 --- 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;