Fix null termination issue of filename and argv[1] 27/177427/1 accepted/tizen/unified/20180504.063600 submit/tizen/20180502.024929
authorJiyong Min <jiyong.min@samsung.com>
Mon, 30 Apr 2018 00:45:56 +0000 (09:45 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Mon, 30 Apr 2018 00:46:52 +0000 (09:46 +0900)
Change-Id: I080a1cbef7ea4b8e4a3913e4e282884d20a30905

imgcv/test/mm_util_imgcv_testsuite.c

index e8bba03..89623af 100755 (executable)
@@ -32,31 +32,26 @@ int main(int argc, char *argv[])
        int ret = 0;
        int width;
        int height;
-       int len;
 
        unsigned char *img_buffer;
        unsigned int  img_buffer_size;
 
-       char filename[MAX_FILENAME_LEN];
-
        if (argc < 1) {
                fprintf(stderr, "Usage: ./mm_imgcv_testsuite filename(jpg format only)\n");
                return ret;
        }
 
-       len = strlen(argv[1]);
-       if (len > MAX_FILENAME_LEN) {
-               fprintf(stderr, "filename is too long\n");
+       if (argv[1] == NULL || strlen(argv[1]) == 0) {
+               fprintf(stderr, "filename is wrong %s\n", argv[1]);
+               fprintf(stderr, "Usage: ./mm_imgcv_testsuite filename(jpg format only)\n");
                return -1;
        }
 
-       strncpy(filename, argv[1], len);
-
        /* decode jpg image */
        mm_util_jpeg_yuv_data decoded;
        memset(&decoded, 0, sizeof(mm_util_jpeg_yuv_data));
 
-       ret = mm_util_decode_from_jpeg_file_with_downscale(filename, MM_UTIL_COLOR_RGB24, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1, &decoded);
+       ret = mm_util_decode_from_jpeg_file_with_downscale(argv[1], MM_UTIL_COLOR_RGB24, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1, &decoded);
 
        if (!ret) {
                img_buffer = decoded.data;