diff mbox series

[2/5] nfsd_path.c: - Simplification of nfsd_path_strip_root(char*)

Message ID 20241206221202.31507-3-christopherbii@hyub.org (mailing list archive)
State Handled Elsewhere
Headers show
Series nfs export symlink vulnerability fix (duplicate(ish)) | expand

Commit Message

Christopher Bii Dec. 6, 2024, 10:11 p.m. UTC
Signed-off-by: Christopher Bii <christopherbii@hyub.org>
---
 support/misc/nfsd_path.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/support/misc/nfsd_path.c b/support/misc/nfsd_path.c
index 5168903d..ff946301 100644
--- a/support/misc/nfsd_path.c
+++ b/support/misc/nfsd_path.c
@@ -55,19 +55,11 @@  nfsd_rootdir_set(void)
 char *
 nfsd_path_strip_root(char *pathname)
 {
-	char buffer[PATH_MAX];
-	const char *dir = nfsd_path_rootdir();
-
-	if (!dir)
-		goto out;
-
-	if (realpath(dir, buffer))
-		return strstr(pathname, buffer) == pathname ?
-			pathname + strlen(buffer) : NULL;
+	if (!rootdir)
+                return pathname;
 
-	xlog(D_GENERAL, "%s: failed to resolve path %s: %m", __func__, dir);
-out:
-	return pathname;
+        return strstr(pathname, rootdir) == pathname ?
+                pathname + rootdir_pathlen : pathname;
 }
 
 char *