浏览代码

FileExtractor: Add sanity checks for negative Int64 values.

Jordan Russell 1 月之前
父节点
当前提交
b51c328fc0
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      Projects/Src/Setup.FileExtractor.pas

+ 4 - 0
Projects/Src/Setup.FileExtractor.pas

@@ -279,6 +279,8 @@ var
   Buffer: Pointer;
   Buffer: Pointer;
   Left, Res: Cardinal;
   Left, Res: Cardinal;
 begin
 begin
+  if (Count < 0) or (FChunkBytesLeft < 0) then  { sanity checks }
+    InternalError('TFileExtractor.ReadProc: Negative count');
   Buffer := @Buf;
   Buffer := @Buf;
   Left := Count;
   Left := Count;
   if FChunkBytesLeft < Left then
   if FChunkBytesLeft < Left then
@@ -322,6 +324,8 @@ begin
   Inc(FEntered);
   Inc(FEntered);
   try
   try
     var BytesLeft := FL.OriginalSize;
     var BytesLeft := FL.OriginalSize;
+    if BytesLeft < 0 then  { sanity check }
+      InternalError('TFileExtractor.DecompressFile: Negative size');
 
 
     { To avoid file system fragmentation, preallocate all of the bytes in the
     { To avoid file system fragmentation, preallocate all of the bytes in the
       destination file }
       destination file }