Library real path maybe not exist, use realpath to check it.
Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com --- wd_util.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/wd_util.c b/wd_util.c index 9cf95bf..d8d6482 100644 --- a/wd_util.c +++ b/wd_util.c @@ -2185,6 +2185,7 @@ static void dladdr_empty(void) {} int wd_get_lib_file_path(char *lib_file, char *lib_path, bool is_dir) { char file_path[PATH_STR_SIZE] = {0}; + char path[PATH_MAX]; Dl_info file_info; int len, rc, i;
@@ -2214,6 +2215,11 @@ int wd_get_lib_file_path(char *lib_file, char *lib_path, bool is_dir) if (len < 0) return -WD_EINVAL;
+ if (realpath(lib_path, path) == NULL) { + WD_ERR("%s: no such file or directory!\n", path); + return -WD_EINVAL; + } + return 0; }