nfs4: Fix parsing paths that begin with '/'

This commit is contained in:
Pawel Dziepak
2012-06-29 02:14:58 +02:00
parent 963a5e658a
commit a90b62049a
@@ -44,10 +44,14 @@ Filesystem::Mount(Filesystem** pfs, RPC::Server* serv, const char* fsPath,
char* path = strdup(fsPath); char* path = strdup(fsPath);
char* pathStart = path; char* pathStart = path;
char* pathEnd; char* pathEnd;
while (pathStart != NULL) { while (pathStart != NULL && pathStart[0] != '\0') {
pathEnd = strpbrk(pathStart, "/"); pathEnd = strpbrk(pathStart, "/");
if (pathEnd != NULL) if (pathEnd != NULL)
*pathEnd = '\0'; *pathEnd = '\0';
if (pathEnd == pathStart) {
pathStart++;
continue;
}
req.LookUp(pathStart); req.LookUp(pathStart);
@@ -106,7 +110,10 @@ Filesystem::Mount(Filesystem** pfs, RPC::Server* serv, const char* fsPath,
reinterpret_cast<FilesystemId*>(values[0].fData.fPointer); reinterpret_cast<FilesystemId*>(values[0].fData.fPointer);
Filesystem* fs = new(std::nothrow) Filesystem; Filesystem* fs = new(std::nothrow) Filesystem;
fs->fPath = strdup(fsPath); if (fsPath != NULL && fsPath[0] == '/')
fs->fPath = strdup(fsPath + 1);
else
fs->fPath = strdup(fsPath + 1);
memcpy(&fs->fRootFH, &fh, sizeof(Filehandle)); memcpy(&fs->fRootFH, &fh, sizeof(Filehandle));
fs->fServer = serv; fs->fServer = serv;
fs->fDevId = id; fs->fDevId = id;