Modify code to use g_strdup() 81/227681/1 accepted/tizen/5.5/unified/20200316.155202 submit/tizen_5.5/20200313.062723
authorhj kim <backto.kim@samsung.com>
Fri, 13 Mar 2020 07:17:02 +0000 (16:17 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Sun, 15 Mar 2020 22:46:32 +0000 (22:46 +0000)
Change-Id: I0d2569df7e7059a9af2994e562b3ecfba04c64d8
(cherry picked from commit 328af909335fdcea73d2079c476cd0b54e86ac2f)

src/mediadb-update.c

index 0d99d1b..ade6326 100755 (executable)
@@ -156,7 +156,7 @@ int main(int argc, char **argv)
        int len;
        char *argv1 = NULL;
        char *argv2 = NULL;
-       char req_path[1024] = {0, };
+       char *req_path = NULL;
 
        if (argc > 3 || argc < 2) {
                __print_help();
@@ -185,13 +185,14 @@ int main(int argc, char **argv)
 
                if (g_file_test(argv1, G_FILE_TEST_IS_DIR)) {
                        len = strlen(argv1);
-                       if (len < sizeof(req_path)) {
-                               if (argv1[len - 1] == '/')
-                                       g_strlcpy(req_path, argv1, len - 1);
-                               else
-                                       g_strlcpy(req_path, argv1, len);
-                       }
+                       if (argv1[len - 1] == '/')
+                               req_path = g_strndup(argv1, len - 1);
+                       else
+                               req_path = g_strdup(argv1);
+
                        ret = dir_scan(req_path, false);
+                       g_free(req_path);
+
                        if (ret != 0) {
                                printf("error : %d\n", ret);
                                exit(0);
@@ -206,14 +207,14 @@ int main(int argc, char **argv)
                if (strcmp(argv1, "-r") == 0) {
                        if ((argv2 != NULL) && (g_file_test(argv2, G_FILE_TEST_IS_DIR))) {
                                len = strlen(argv2);
-                               if (len < sizeof(req_path)) {
-                                       if (argv2[len - 1] == '/')
-                                               g_strlcpy(req_path, argv2, len - 1);
-                                       else
-                                               g_strlcpy(req_path, argv2, len);
-                               }
+                               if (argv2[len - 1] == '/')
+                                       req_path = g_strndup(argv2, len - 1);
+                               else
+                                       req_path = g_strdup(argv2);
 
                                ret = dir_scan(req_path, true);
+                               g_free(req_path);
+
                                if (ret != 0) {
                                        printf("error : %d\n", ret);
                                        exit(0);