Explorar el Código

Skip loop when Length=0.

Length is unsigned, so "Length-1" will underflow to $FFFFFFFF.
Jordan Russell hace 1 año
padre
commit
a7d5ed9d90
Se han modificado 1 ficheros con 3 adiciones y 0 borrados
  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;