diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-09-24 15:21:35 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-09-24 15:21:35 +0100 |
commit | 8d9bd52f88cfbe82d7f5e10d0b86b9c2830a939b (patch) | |
tree | 03008ab7076c3b87bde72fdb40939fa5257f26b6 /src/libutil/http.c | |
parent | aea4474a10cafb54da4c5d5c1b508ec7adb239ef (diff) | |
download | rspamd-8d9bd52f88cfbe82d7f5e10d0b86b9c2830a939b.tar.gz rspamd-8d9bd52f88cfbe82d7f5e10d0b86b9c2830a939b.zip |
Try to fix crashes when GString is reallocated.
Issue: #381
Diffstat (limited to 'src/libutil/http.c')
-rw-r--r-- | src/libutil/http.c | 13 |
1 files 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; |