From: Vsevolod Stakhov Date: Fri, 22 Jan 2021 15:49:38 +0000 (+0000) Subject: [Minor] Fix some issues found X-Git-Tag: 3.0~738 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f64087e3f991ccab5b3556c02fe7d13a247cda54;p=rspamd.git [Minor] Fix some issues found --- diff --git a/src/libserver/css/css_parser.cxx b/src/libserver/css/css_parser.cxx index 99798b844..4134b933c 100644 --- a/src/libserver/css/css_parser.cxx +++ b/src/libserver/css/css_parser.cxx @@ -155,23 +155,23 @@ css_parser::unescape_css(const std::string_view &sv) const auto *escape_start = &sv[escape_offset + 1]; unsigned long val; - if (!rspamd_xstrtoul (escape_start, i - escape_offset - 1, &val)) { + if (!rspamd_xstrtoul(escape_start, i - escape_offset - 1, &val)) { msg_debug_css("invalid broken escape found at pos %d", escape_offset); } else { - if (val < 0x1f) { + if (val < 0x80) { /* Trivial case: ascii character */ *d++ = (unsigned char)val; nleft --; } else { UChar32 uc = val; - auto off = d - nspace; + auto off = 0; UTF8_APPEND_CHAR_SAFE((uint8_t *) d, off, sv.length (), uc); - d = nspace + off; - nleft = sv.length () - off; + d += off; + nleft -= off; } } } @@ -181,7 +181,7 @@ css_parser::unescape_css(const std::string_view &sv) escape_offset); } - if (nleft > 0) { + if (nleft <= 0) { msg_err_css("cannot unescape css: truncated buffer of size %d", (int)sv.length()); }