From: Vsevolod Stakhov Date: Thu, 20 Aug 2015 16:09:50 +0000 (+0100) Subject: Simplify colors parsing. X-Git-Tag: 1.0.0~179 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=454516df4cabdfc38d5d4cdbdf6a37d9292a94c0;p=thirdparty%2Frspamd.git Simplify colors parsing. --- diff --git a/src/libserver/html.c b/src/libserver/html.c index 0478816cc3..c679c07bb5 100644 --- a/src/libserver/html.c +++ b/src/libserver/html.c @@ -1400,7 +1400,7 @@ static void rspamd_html_process_color (const gchar *line, guint len, struct html_color *cl) { const gchar *p = line, *end = line + len; - char hexbuf[3] = {0, 0, 0}; + char hexbuf[7]; rspamd_fstring_t search; struct html_color_match *el; @@ -1409,21 +1409,8 @@ rspamd_html_process_color (const gchar *line, guint len, struct html_color *cl) if (*p == '#') { /* HEX color */ p ++; - - if (end - p >= 2) { - memcpy (hexbuf, p, 2); - cl->d.comp.r = strtoul (hexbuf, NULL, 16); - } - p += 2; - if (end - p >= 2) { - memcpy (hexbuf, p, 2); - cl->d.comp.g = strtoul (hexbuf, NULL, 16); - } - p += 2; - if (end - p >= 2) { - memcpy (hexbuf, p, 2); - cl->d.comp.b = strtoul (hexbuf, NULL, 16); - } + rspamd_strlcpy (hexbuf, p, MIN ((gint)sizeof(hexbuf), end - p + 1)); + cl->d.val = strtoul (hexbuf, NULL, 16); } else { /* Compare color by name */