diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-08-21 15:04:35 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-08-21 15:04:35 +0100 |
commit | 4201529a7c3c4844ef53dd1d5761e13b9649b5e5 (patch) | |
tree | 0194e4062a07c8d16c2c47edab6d2ae580ba6436 /src/libserver | |
parent | 23d309a5330c47ad682ecc5b63c0de5bdf68a8d7 (diff) | |
download | rspamd-4201529a7c3c4844ef53dd1d5761e13b9649b5e5.tar.gz rspamd-4201529a7c3c4844ef53dd1d5761e13b9649b5e5.zip |
[Minor] Fix entities decoding
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/html.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/libserver/html.c b/src/libserver/html.c index 4b100cc43..79d4eebb3 100644 --- a/src/libserver/html.c +++ b/src/libserver/html.c @@ -338,6 +338,7 @@ rspamd_html_decode_entitles_inplace (gchar *s, guint len) { guint l, rep_len; gchar *t = s, *h = s, *e = s, *end_ptr; + const gchar *end; const gchar *entity; gint state = 0, val, base; khiter_t k; @@ -349,6 +350,8 @@ rspamd_html_decode_entitles_inplace (gchar *s, guint len) l = len; } + end = s + l; + while (h - s < (gint)l) { switch (state) { /* Out of entity */ @@ -379,13 +382,13 @@ rspamd_html_decode_entitles_inplace (gchar *s, guint len) if (kh_val (html_entity_by_name, k)) { rep_len = strlen (kh_val (html_entity_by_name, k)); - if (end_ptr - t >= rep_len) { + if (end - t >= rep_len) { memcpy (t, kh_val (html_entity_by_name, k), rep_len); t += rep_len; } } else { - if (end_ptr - t >= h - e) { + if (end - t >= h - e) { memmove (t, e, h - e); t += h - e; } @@ -411,7 +414,7 @@ rspamd_html_decode_entitles_inplace (gchar *s, guint len) if (end_ptr != NULL && *end_ptr != '\0') { /* Skip undecoded */ - if (end_ptr - t >= h - e) { + if (end - t >= h - e) { memmove (t, e, h - e); t += h - e; } @@ -424,13 +427,13 @@ rspamd_html_decode_entitles_inplace (gchar *s, guint len) if (kh_val (html_entity_by_number, k)) { rep_len = strlen (kh_val (html_entity_by_number, k)); - if (end_ptr - t >= rep_len) { + if (end - t >= rep_len) { memcpy (t, kh_val (html_entity_by_number, k), rep_len); t += rep_len; } } else { - if (end_ptr - t >= h - e) { + if (end - t >= h - e) { memmove (t, e, h - e); t += h - e; } |