From 8b74294ece38dae6e2a05d79fceab80c8795513a Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 11 Oct 2019 10:46:56 +0100 Subject: [PATCH] [Minor] Fix some corner cases in HTML parsing --- src/libserver/html.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libserver/html.c b/src/libserver/html.c index dbbefd10c..de6e104b4 100644 --- a/src/libserver/html.c +++ b/src/libserver/html.c @@ -350,7 +350,7 @@ rspamd_html_decode_entitles_inplace (gchar *s, gsize len) khiter_t k; if (len == 0) { - l = strlen (s); + return 0; } else { l = len; @@ -871,7 +871,10 @@ rspamd_html_parse_tag_component (rspamd_mempool_t *pool, gboolean ret = FALSE; gchar *p; - g_assert (end >= begin); + if (end <= begin) { + return FALSE; + } + p = rspamd_mempool_alloc (pool, end - begin); memcpy (p, begin, end - begin); len = rspamd_html_decode_entitles_inplace (p, end - begin); -- 2.39.5