commit f64087e: [Minor] Fix some issues found

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Jan 22 16:00:34 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-01-22 15:49:38 +0000
URL: https://github.com/rspamd/rspamd/commit/f64087e3f991ccab5b3556c02fe7d13a247cda54

[Minor] Fix some issues found

---
 src/libserver/css/css_parser.cxx | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

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());
 				}


More information about the Commits mailing list