From: Philip Withnall Date: Wed, 21 Dec 2011 20:09:47 +0000 (+0000) Subject: Bug 666540 — Segfault on empty e-mail addresses with potential match X-Git-Tag: FOLKS_0_6_7~54 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6d9b0f55ff057776c13a2a6927a853ba6e9a320d;p=platform%2Fupstream%2Ffolks.git Bug 666540 — Segfault on empty e-mail addresses with potential match Gracefully handle invalid e-mail addresses (such as empty strings or strings not containing an ‘@’) when searching for potential matches. Closes: bgo#666540 --- diff --git a/NEWS b/NEWS index eee9353..1cfc30a 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ Overview of changes from libfolks 0.6.6 to libfolks 0.6.7 Bugs fixed: * Bug 666310 — Crash in Tracker backend by unsetting an entry in a read-only map * Bug 666528 — Can't convert from type 'GFile' to 'gchararray' +* Bug 666540 — Segfault on empty e-mail addresses with potential match Overview of changes from libfolks 0.6.5 to libfolks 0.6.6 ============================================================= diff --git a/folks/potential-match.vala b/folks/potential-match.vala index 82e2e13..eb4906c 100644 --- a/folks/potential-match.vala +++ b/folks/potential-match.vala @@ -254,11 +254,31 @@ public class Folks.PotentialMatch : Object foreach (var fd_a in set_a) { + string[] email_split_a = fd_a.value.split ("@"); + + /* Sanity check for valid e-mail addresses. */ + if (email_split_a.length < 2) + { + warning ("Invalid e-mail address when looking for potential " + + "match: %s", fd_a.value); + continue; + } + + string[] tokens_a = + email_split_a[0].split_set (this._SEPARATORS); + foreach (var fd_b in set_b) { - string[] email_split_a = fd_a.value.split ("@"); string[] email_split_b = fd_b.value.split ("@"); + /* Sanity check for valid e-mail addresses. */ + if (email_split_b.length < 2) + { + warning ("Invalid e-mail address when looking for " + + "potential match: %s", fd_b.value); + continue; + } + if (fd_a.value == fd_b.value) { if (PotentialMatch.known_email_aliases.contains @@ -277,8 +297,6 @@ public class Folks.PotentialMatch : Object } else { - string[] tokens_a = - email_split_a[0].split_set (this._SEPARATORS); string[] tokens_b = email_split_b[0].split_set (this._SEPARATORS);