From a2d4ea58437d93297c7f7e2e8efd4d48297ca46a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Droz?= Date: Tue, 26 Nov 2013 21:17:43 +0100 Subject: [PATCH] vcard built-in import: fix segfaults when a subset of vcard ADR fields are provided (and/or a trailing semi-colon appended). Reported-by: Gaetan Bisson --- filter.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/filter.c b/filter.c index 338c640..7f8bcd5 100644 --- a/filter.c +++ b/filter.c @@ -1660,20 +1660,33 @@ vcard_parse_address(list_item item, char *line) // vCard(post office box) - not used strsep(&value, ";"); + if(!value) return; + // vCard(the extended address) item_fput(item, ADDRESS2, xstrdup(strsep(&value, ";"))); + if(!value) return; + // vCard(the street address) item_fput(item, ADDRESS, xstrdup(strsep(&value, ";"))); + if(!value) return; + // vCard(the locality) item_fput(item, CITY, xstrdup(strsep(&value, ";"))); + if(!value) return; + // vCard(the region) item_fput(item, STATE, xstrdup(strsep(&value, ";"))); + if(!value) return; + // vCard(the postal code) item_fput(item, ZIP, xstrdup(strsep(&value, ";"))); + if(!value) return; + // vCard(the country name) item_fput(item, COUNTRY, xstrdup(strsep(&value, ";"))); - if(*value) xfree(value); + // support of optional trailing ";" to the ADR field + if(value && *value) xfree(value); } static void -- 2.39.5