[geary: 1/2] Fix 100% CPU usage on mismatch utf escapes in rfc822 string
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary: 1/2] Fix 100% CPU usage on mismatch utf escapes in rfc822 string
- Date: Wed, 7 Aug 2019 00:50:58 +0000 (UTC)
commit 15e0d18dd66e5387361e354d2b6e0a0876b3ddbb
Author: Joe Barnett <jbarnett tribedynamics com>
Date: Tue Aug 6 07:30:28 2019 -0700
Fix 100% CPU usage on mismatch utf escapes in rfc822 string
Since we're adding 2 to the index_of return value, we can't
compare to -1.
See issue #504
src/engine/rfc822/rfc822-mailbox-address.vala | 2 +-
test/engine/rfc822-mailbox-address-test.vala | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/src/engine/rfc822/rfc822-mailbox-address.vala b/src/engine/rfc822/rfc822-mailbox-address.vala
index 4ab8d21e..73803f19 100644
--- a/src/engine/rfc822/rfc822-mailbox-address.vala
+++ b/src/engine/rfc822/rfc822-mailbox-address.vala
@@ -131,7 +131,7 @@ public class Geary.RFC822.MailboxAddress :
while ((start = text.index_of("=?", offset)) != -1) {
// Find the closing marker.
int end = text.index_of("?=", start + 2) + 2;
- if (end == -1) {
+ if (end <= 1) {
end = text.length;
}
diff --git a/test/engine/rfc822-mailbox-address-test.vala b/test/engine/rfc822-mailbox-address-test.vala
index b3f7547d..c04d47e0 100644
--- a/test/engine/rfc822-mailbox-address-test.vala
+++ b/test/engine/rfc822-mailbox-address-test.vala
@@ -147,6 +147,11 @@ class Geary.RFC822.MailboxAddressTest : TestCase {
addr = new
MailboxAddress.from_rfc822_string("\"=?utf-8?Q?=42=45=47=49=4E=20=2F=20=28=7C=29=7C=3C=7C=3E=7C=40=7C=2C=7C=3B=7C=3A=7C=5C=7C=22=7C=2F=7C=5B=7C=5D=7C=3F=7C=2E=7C=3D=20=2F=20=00=20=50=41=53=53=45=44=20=4E=55=4C=4C=20=42=59=54=45=20=2F=20=0D=0A=20=50=41=53=53=45=44=20=43=52=4C=46=20=2F=20?==?utf-8?b?RU5E=?=\"");
assert(addr.name == null);
assert(addr.address == "BEGIN / (|)|<|>|@|,|;|:|\\|\"|/|[|]|?|.|= / ? PASSED NULL BYTE / \r\n
PASSED CRLF / END");
+
+ addr = new
MailboxAddress.from_rfc822_string("=?UTF-8?Q?=22Firstname_=22=C2=AF\\=5F=28=E3=83=84=29=5F/=C2=AF=22_Lastname_via?==?UTF-8?Q?_Vendor=22_<system
vendor com>?=");
+ assert(addr.name == "Firstname ¯_(ツ)_/¯ Lastname via=?UTF-8?Q?_Vendor=22_");
+ assert(addr.mailbox == "system");
+ assert(addr.domain == "vendor.com");
} catch (Error err) {
assert_not_reached();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]