Explorar o código

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 %!s(int64=8) %!d(string=hai) anos
pai
achega
ab6cce6bfe
Modificáronse 1 ficheiros con 2 adicións e 3 borrados
  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);