Whamcloud - gitweb
LU-12703 utils: reset rootpath in llapi_search_rootpath() 82/36482/3
authorAlex Zhuravlev <bzzz@whamcloud.com>
Mon, 30 Sep 2019 20:50:49 +0000 (23:50 +0300)
committerOleg Drokin <green@whamcloud.com>
Thu, 5 Dec 2019 14:56:58 +0000 (14:56 +0000)
as get_root_path() can use it as a source and fail if
passed pathname contains garbage (on stack);

Lustre-change: https://review.whamcloud.com/36335
Lustre-commit: 3e2e0025d1e929763f9d4de48746c3433d3684d5

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I9f628353c872afc82a582b0a6ca960cd0e8cffcb
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/36482
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/utils/liblustreapi.c

index 6112b46..4985294 100644 (file)
@@ -1343,6 +1343,9 @@ int llapi_search_fsname(const char *pathname, char *fsname)
 
 int llapi_search_rootpath(char *pathname, const char *fsname)
 {
+       /* pathname can be used as an argument by get_root_path(),
+        * clear it for safety */
+       pathname[0] = 0;
        return get_root_path(WANT_PATH, (char *)fsname, NULL, pathname, -1);
 }