SVACE: HEAP_LEAK, correct size in strncpy
[platform/core/security/tef-simulator.git] / ssflib / dep / swdss / source / file_op.cpp
index 38d135d..eafe680 100644 (file)
@@ -230,14 +230,10 @@ bool file_op::is_file_exists(const char* file) {
 }
 
 void file_op::get_base_path(const char* filename, char* base_path) {
-       char tmp[256] = {0};
-       memcpy(tmp, filename, strlen(filename));
-
        for (int i = strlen(filename) - 1; i >= 0; --i) {
-               tmp[i] = 0;
-
                if ('/' == filename[i]) {
-                       memcpy(base_path, tmp, strlen(tmp));
+                       memcpy(base_path, filename, i);
+                       base_path[i] = '\0';
                        break;
                }
        }