Modify recorded_date conversion for data overflow 47/89947/3 accepted/tizen/3.0/ivi/20161011.044414 accepted/tizen/common/20160928.163916 accepted/tizen/ivi/20160930.040737 accepted/tizen/mobile/20160930.040403 accepted/tizen/tv/20160930.040547 accepted/tizen/wearable/20160930.040645 submit/tizen/20160928.043825 submit/tizen_3.0_ivi/20161010.000003
authorJiyong Min <jiyong.min@samsung.com>
Tue, 27 Sep 2016 23:37:10 +0000 (08:37 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Wed, 28 Sep 2016 01:14:57 +0000 (10:14 +0900)
 - PROBLEM
 64byte array will make data overflow when p(tag) is over 64 byte.

[version] 0.2.83
[solution] Remove fixed size array and replace it to memory allocation

Change-Id: I8d7f3b5b496abaf822dad7df15d10c7473a9d4c1
Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
packaging/libmedia-service.spec
src/common/media-svc-util.c

index c2d1c660cb267a405d827f65f28914c88d3cba0b..8d209fa59ade212c6fc0bffd65d2c78ff404eca7 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmedia-service
 Summary:    Media information service library for multimedia applications
-Version: 0.2.82
+Version: 0.2.83
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0 and public domain
index 60642a96a6024dd21240abb607875ec5a96f37a1..b448539fb9be041cfd6f1385e5e459e10aec73d4 100755 (executable)
@@ -1991,23 +1991,25 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s
                if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
                        if (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
                                /*Creation time format is 2013-01-01 00:00:00. change it to 2013:01:01 00:00:00 like exif time format*/
-                               char time_info[64] = {0, };
-                               char p_value[64] = {0, };
-                               int idx = 0;
-                               memset(time_info, 0x00, sizeof(time_info));
-                               memset(p_value, 0x00, sizeof(p_value));
-                               strncpy(p_value, p, size);
-                               for (idx = 0; idx < size; idx++) {
-                                       if (p_value[idx] == '-') {
-                                               time_info[idx] = ':';
-                                       } else if (p_value[idx] != '\0') {
-                                               time_info[idx] = p_value[idx];
-                                       } else {
-                                               media_svc_error("strcpy error");
-                                               break;
+                               char *time_info = (char*)calloc(1, (size + 1));
+                               char *p_value = p;
+                               char *time_value = time_info;
+                               if (time_info != NULL) {
+                                       while(*p_value != '\0') {
+                                               if (*p_value == '-')
+                                                       *time_value = ':';
+                                               else
+                                                       *time_value = *p_value;
+                                               time_value++;
+                                               p_value++;
                                        }
+                                       *time_value = '\0';
+                                       ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.recorded_date, time_info);
+                                       SAFE_FREE(time_info);
+                               } else {
+                                       media_svc_error("memory allocation error");
+                                       ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
                                }
-                               ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.recorded_date, time_info);
                        } else {
                                ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.recorded_date, p);
                        }