From: jk.koo Date: Fri, 3 Apr 2020 05:30:59 +0000 (+0900) Subject: Fix crash issues when inserting a vcard which has custom type data X-Git-Tag: submit/tizen/20200409.163033^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b9422797a19bdece3788fef29e5ade850c2df6b0;hp=92e1e3dd3dadb4f077d7d864beea7aa0e8d168e6;p=platform%2Fcore%2Fpim%2Fcontacts-service.git Fix crash issues when inserting a vcard which has custom type data Change-Id: I8441750f96b365b2f2e148913560092e4b5b5b82 Signed-off-by: jk.koo --- diff --git a/common/ctsvc_vcard.c b/common/ctsvc_vcard.c index 70e20ec..9b2b9bc 100644 --- a/common/ctsvc_vcard.c +++ b/common/ctsvc_vcard.c @@ -2390,6 +2390,33 @@ static int __ctsvc_vcard_check_content_type(char **vcard) } } +static bool __ctsvc_vcard_has_unsupported_format(const char *row) +{ + RETV_IF(NULL == row, false); + + char *xcustom1 = strstr(row, "XCUSTOM"); + char *xcustom2 = strstr(row, "X-CUSTOM"); + char *quoted1 = strstr(row, "QUOTEDPRINTABLE"); + char *quoted2 = strstr(row, "QUOTED-PRINTABLE"); + char *end_of_raw = strchr(row, '\n'); + bool has_xcustom = false; + bool has_quoted = false; + + if ((xcustom1 != NULL && xcustom1 < end_of_raw) ||(xcustom2 != NULL && xcustom2 < end_of_raw)) + has_xcustom = true; + + if ((quoted1 != NULL && quoted1 < end_of_raw) ||(quoted2 != NULL && quoted2 < end_of_raw)) + has_quoted = true; + + /* quoted-printable is not supported in custom type */ + if (has_xcustom && has_quoted) { + INFO("This row has unsupported format"); + return true; + } + + return false; +} + static inline char* __ctsvc_vcard_pass_unsupported(char *vcard) { while (*vcard) { @@ -2593,7 +2620,7 @@ static inline char* __ctsvc_vcard_translate_charset(char *src, int len) return NULL; } -static void __ctsvc_vcard_get_prefix(char **prefix, char *src) +static void __ctsvc_vcard_get_prefix(char **prefix, const char *src) { char *temp = strchr(src, ':'); if (temp) { @@ -3948,7 +3975,7 @@ static inline int __ctsvc_vcard_get_contact(int ver, char *vcard, contacts_recor bool base64_encoded = false; type = __ctsvc_vcard_check_content_type(&cursor); - if (CTSVC_VCARD_VALUE_NONE == type) { + if (CTSVC_VCARD_VALUE_NONE == type || __ctsvc_vcard_has_unsupported_format(cursor)) { new_start = __ctsvc_vcard_pass_unsupported(cursor); if (new_start) { cursor = new_start;