Przeglądaj źródła

Skip loop when Length=0.

Length is unsigned, so "Length-1" will underflow to $FFFFFFFF.
Jordan Russell 1 rok temu
rodzic
commit
a7d5ed9d90
1 zmienionych plików z 3 dodań i 0 usunięć
  1. 3 0
      Components/ChaCha20.pas

+ 3 - 0
Components/ChaCha20.pas

@@ -129,6 +129,9 @@ procedure ChaCha20Crypt(var Context: TChaCha20Context; const InBuffer;
   end;
 
 begin
+  if Length = 0 then
+    Exit;
+
   var InBuf: PByte := @InBuffer;
   var OutBuf: PByte := @OutBuffer;
   var KeyStream: PByte := @Context.keystream;