tizen 2.4 release
[framework/security/key-manager.git] / tools / ckm_so_loader.cpp
index a39adb6..2af4d06 100644 (file)
@@ -94,12 +94,27 @@ int main(int argc, char* argv[])
     string so_path(argv[3]);
     string symbol(argv[4]);
 
+    /*
+     *  perform sanity check of user input string
+     *  which will be used for dlopen
+     */
+    if (so_path.compare(so_path.size() - 3, 3, ".so")
+        && so_path.compare(so_path.size() - 5, 3, ".so")
+        && so_path.compare(so_path.size() - 9, 3, ".so")) {
+        cerr << "[" << so_path << "] doesn't has .so postfix." << endl;
+        return -1;
+    }
+    if (access(so_path.c_str(), R_OK)) {
+        cerr << "cannot read [" << so_path << "]" << endl;
+        return -1;
+    }
+
     cout << "dlopen[us];dlsym[us]" << endl;
     for (int cnt = 0 ; cnt < repeats; cnt++)
     {
         /*
-         * It has to be a different process each time. Glibc somehow caches the library information
-         * and consecutive calls are faster
+         *  It has to be a different process each time. Glibc somehow caches the library information
+         *  and consecutive calls are faster
          */
         pid_t pid = fork();
         if (pid < 0) {