浏览代码

Strengthen CreateFileW's check.

Martijn Laan 10 月之前
父节点
当前提交
aa1e83a139
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      Projects/Src/Compression.SevenZipDecoder.pas

+ 2 - 1
Projects/Src/Compression.SevenZipDecoder.pas

@@ -75,7 +75,8 @@ function __CreateFileW(lpFileName: LPCWSTR; dwDesiredAccess, dwShareMode: DWORD;
 begin
   var ExpandedFileName: String;
   if PathExpand(lpFileName, ExpandedFileName) and
-     ((PathCompare(ExpandedFileName, State.ExpandedArchiveFileName) = 0) or PathStartsWith(ExpandedFileName, State.ExpandedDestDir)) then
+     (((dwDesiredAccess = GENERIC_READ) and (PathCompare(ExpandedFileName, State.ExpandedArchiveFileName) = 0)) or
+      ((dwDesiredAccess = GENERIC_WRITE) and PathStartsWith(ExpandedFileName, State.ExpandedDestDir))) then
     Result := CreateFileW(PChar(ExpandedFileName), dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile)
   else begin
     Result := INVALID_HANDLE_VALUE;