소스 검색

HPCC-16105 Fileservices checkExternalFileRights() incorrect check

In fileservices.cpp, method checkExternalFileRights accepts 2 flags indicating
it should test for read, and one for write. The "if" statement presumes that
only one of these can be true. Additionally, the "extpath" variable is never
set, so the code never checks the specified file. This PR sets the path
variable correctly, and checks for both read and write perms independently.

Signed-off-by: Russ Whitehead <william.whitehead@lexisnexis.com>
Russ Whitehead 8 년 전
부모
커밋
ab6cce6bfe
1개의 변경된 파일2개의 추가작업 그리고 3개의 파일을 삭제
  1. 2 3
      plugins/fileservices/fileservices.cpp

+ 2 - 3
plugins/fileservices/fileservices.cpp

@@ -2147,7 +2147,7 @@ FILESERVICES_API char *  FILESERVICES_CALL fsfResolveHostName(const char *hostna
 
 static void checkExternalFileRights(ICodeContext *ctx, CDfsLogicalFileName &lfn, bool rd,bool wr)
 {
-    StringAttr extpath;
+    StringAttr extpath(lfn.get());
     Linked<IUserDescriptor> udesc = ctx->queryUserDescriptor();
     unsigned auditflags = 0;
     if (rd)
@@ -2160,14 +2160,13 @@ static void checkExternalFileRights(ICodeContext *ctx, CDfsLogicalFileName &lfn,
             throw MakeStringException(-1,"Write permission denied for %s",extpath.get());
         }
     }
-    else if (rd) {
+    if (rd) {
         if (!HASREADPERMISSION(perm)) {
             throw MakeStringException(-1,"Read permission denied for %s",extpath.get());
         }
     }
 }
 
-
 FILESERVICES_API void  FILESERVICES_CALL fsMoveExternalFile(ICodeContext * ctx,const char *location,const char *frompath,const char *topath)
 {
     SocketEndpoint ep(location);