]> git.deb.at Git - pkg/abook.git/commitdiff
vcard built-in import: fix segfaults when a subset of vcard ADR fields
authorRaphaël Droz <raphael.droz+floss@gmail.com>
Tue, 26 Nov 2013 20:17:43 +0000 (21:17 +0100)
committerRaphaël Droz <raphael.droz+floss@gmail.com>
Tue, 26 Nov 2013 20:17:43 +0000 (21:17 +0100)
 are provided (and/or a trailing semi-colon appended).

Reported-by: Gaetan Bisson <bisson@archlinux.org>
filter.c

index 338c6402bad0a824f1a80d9b871fcd7861d262df..7f8bcd5ce3da16f61d61fa0b670b8ae44dbbc1e6 100644 (file)
--- 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