浏览代码

HPCC-13060 Ensure CreateExternalDirectory passes LFN validation

It's reasonable to have a trailing path seperator, when calling
CreateExternalDirectory, but it fell foul of the normalizeLFN
validation.
Ensure it passes by stripping trailing path separator if present.

Signed-off-by: Jake Smith <jake.smith@lexisnexis.com>
Jake Smith 10 年之前
父节点
当前提交
abebd52d4d
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      plugins/fileservices/fileservices.cpp

+ 8 - 2
plugins/fileservices/fileservices.cpp

@@ -2161,12 +2161,18 @@ FILESERVICES_API void  FILESERVICES_CALL fsDeleteExternalFile(ICodeContext * ctx
     AuditMessage(ctx,"DeleteExternalFile",path);
 }
 
-FILESERVICES_API void  FILESERVICES_CALL fsCreateExternalDirectory(ICodeContext * ctx,const char *location,const char *path)
+FILESERVICES_API void  FILESERVICES_CALL fsCreateExternalDirectory(ICodeContext * ctx,const char *location,const char *_path)
 {
     SocketEndpoint ep(location);
     if (ep.isNull())
-        throw MakeStringException(-1,"fsCreateExternalDirectory: Cannot resolve location %s",location);
+        throw MakeStringException(-1, "fsCreateExternalDirectory: Cannot resolve location %s",location);
     CDfsLogicalFileName lfn;
+    StringBuffer path(_path);
+    if (0 == path.length())
+        throw MakeStringException(-1, "fsCreateExternalDirectory: empty directory");
+    // remove trailing path separator if present to make it look like a regular LFN after lfn.setExternal
+    if (isPathSepChar(path.charAt(path.length()-1)))
+        path.remove(path.length()-1, 1);
     lfn.setExternal(location,path);
     checkExternalFileRights(ctx,lfn,false,true);
     RemoteFilename rfn;