[balsa] Fix crash using incomplete VCard items



commit 1acbc01615fff7c427de82dc6d9885ea47b0cebd
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue Jun 18 12:25:23 2019 -0400

    Fix crash using incomplete VCard items
    
    * libbalsa/address.c (vcard_strsplit): Ensure that the array
      contains always 5 items.

 ChangeLog          | 7 +++++++
 libbalsa/address.c | 7 +++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9e77f87e6..c9cd34fa0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-06-18  Albrecht Dreß  <albrecht dress arcor de>
+
+       Fix crash using incomplete VCard items
+
+       * libbalsa/address.c (vcard_strsplit): Ensure that the array
+         contains always 5 items.
+
 2019-06-11  Peter Bloomfield  <pbloomfield bellsouth net>
 
        Add -Wredundant-decls -Wshadow -Wformat-security compiler warnings
diff --git a/libbalsa/address.c b/libbalsa/address.c
index 6c4500d2f..a445ca88d 100644
--- a/libbalsa/address.c
+++ b/libbalsa/address.c
@@ -296,9 +296,12 @@ vcard_strsplit(const gchar * string)
        string_list = g_slist_prepend(string_list, g_strdup(remainder));
     }
 
-    str_array = g_new(gchar*, n + 1);
+    if (n < 5U) {
+       str_array = g_new0(gchar*, 5U);
+    } else {
+       str_array = g_new0(gchar*, n + 1);
+    }
 
-    str_array[n] = NULL;
     for (slist = string_list; slist; slist = slist->next) {
        gchar * str = (gchar *) slist->data;
        gchar * p;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]