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) {