From: Raphaƫl Droz Date: Tue, 26 Nov 2013 20:17:43 +0000 (+0100) Subject: vcard built-in import: fix segfaults when a subset of vcard ADR fields X-Git-Tag: upstream/0.6.1~2^2~13 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=a2d4ea58437d93297c7f7e2e8efd4d48297ca46a;p=pkg%2Fabook.git 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 --- 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