[TNEXT-4592] Fix bug: check invalid stream 12/156412/1 accepted/tizen/unified/20171019.060938 submit/tizen/20171018.092814
authorJeesun Kim <iamjs.kim@samsung.com>
Wed, 18 Oct 2017 08:31:03 +0000 (17:31 +0900)
committerJeesun Kim <iamjs.kim@samsung.com>
Wed, 18 Oct 2017 08:31:39 +0000 (17:31 +0900)
Change-Id: I7bb2cf5072298280105960bf50f2be7b12b7b563

common/cal_vcalendar_parse.c

index 889e24f..d478e8f 100644 (file)
@@ -448,9 +448,10 @@ static char* __get_value(char *cursor, char **value)
 
        int i = 0;
        while (VCAL_LF != *(cursor + offset + i)) {
-               if ('\0' == *(cursor + offset + i))
+               if ('\0' == *(cursor + offset + i)) {
+                       DBG("Invalid value");
                        return NULL;
-
+               }
                i++;
        }
 
@@ -3561,6 +3562,8 @@ int cal_vcalendar_parse_vcalendar_object(char *stream, calendar_list_h list, vca
                switch (index) {
                case VCAL_PROPERTY_VERSION:
                        cursor = __get_value(cursor, &value);
+                       if (NULL == cursor)
+                               break;
                        __get_version(value, &ud->version);
                        free(value);
                        value = NULL;
@@ -3570,6 +3573,8 @@ int cal_vcalendar_parse_vcalendar_object(char *stream, calendar_list_h list, vca
                        if (ud->timezone_tzid)
                                break;
                        cursor = __get_value(cursor, &value);
+                       if (NULL == cursor)
+                               break;
                        __get_tz(value + 1, &ud->timezone_tzid);
                        __adjust_tzid(ud->timezone_tzid);
                        DBG("timezone_tzid[%s]", ud->timezone_tzid);
@@ -3579,6 +3584,8 @@ int cal_vcalendar_parse_vcalendar_object(char *stream, calendar_list_h list, vca
 
                case VCAL_PROPERTY_BEGIN: /* BEGIN:VEVENT */
                        cursor = __work_property_begin(cursor, &record, ud);
+                       if (NULL == cursor)
+                               break;
                        calendar_list_add(list, record);
                        count++;
                        if (foreach_data) {