Apply SAFE_STRLCPY 05/172805/1 submit/tizen/20180316.051336
authorJiyong Min <jiyong.min@samsung.com>
Fri, 16 Mar 2018 04:56:26 +0000 (13:56 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Fri, 16 Mar 2018 04:57:04 +0000 (13:57 +0900)
Change-Id: I2e5d1d19292b1116125f55bb8a3ba9a09552196e

common/include/mm_util_private.h
magick/mm_util_info.c
magick/mm_util_magick.c

index 49c726a..ea4f20c 100755 (executable)
@@ -38,6 +38,8 @@ extern "C" {
 #define MMUTIL_SAFE_STRCPY(dst, src, n)        g_strlcpy(dst, src, n)
 #define MMUTIL_STRING_VALID(str)       ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
 
+#define SAFE_STRLCPY(dst, src, n)      g_strlcpy(dst, src, n);
+
 /* for alignment */
 #define MM_UTIL_ROUND_UP_2(num) (((num)+1)&~1)
 #define MM_UTIL_ROUND_UP_4(num) (((num)+3)&~3)
index 19377bc..82db411 100755 (executable)
@@ -229,7 +229,7 @@ static int _ImgGetFileExt(const char *path, char *file_ext, int max_len)
 
        for (i = (int)strlen(path); i >= 0; i--) {
                if ((path[i] == '.') && (i < (int)strlen(path))) {
-                       strncpy(file_ext, &path[i + 1], max_len);
+                       SAFE_STRLCPY(file_ext, &path[i + 1], max_len);
                        return MM_UTIL_ERROR_NONE;
                }
 
index 1b19241..6660502 100755 (executable)
@@ -284,7 +284,7 @@ static int __mm_util_write_image_to_file(ImageInfo *image_info, Image *image, co
 
        GetExceptionInfo(&exception);
 
-       strncpy(image->filename, out_path, sizeof(image->filename));
+       SAFE_STRLCPY(image->filename, out_path, sizeof(image->filename));
        image->filename[MaxTextExtent-1] = '\0';
 
        AddDefinition(image_info, "jpeg", "dct-method", "FASTEST", &exception);