diff -uNr a/vtools/manifest b/vtools/manifest --- a/vtools/manifest 6e0728447dd05a8e1d4dd21a9647ac87e1e66b16e1cb15dca1a9e775907767fcae8b4db6be152aba863bee3bf15cfb665512a45f001593bfd990b43e4087d3ef +++ b/vtools/manifest 1f6a6754f578117a08bc3b4428801c6dbcfd04e5266de39188dc9401ed1b2cf0d33d41a47fb37480ccae92e3a5d4adde71b398f538a6d1e92effb23801b584d8 @@ -8,3 +8,4 @@ 517100 phf vtools_vpatch_newline Vpatch tool support for "No newline at end of file" directive. 543200 phf vtools_ksum Ksum standalone keccak hasher 547300 bvt vtools_tempfile_standalone_notmp Standalone temporary file generation code; creates temporary files in the vpatch work directory. +584341 bvt vdiff_blockwise_read Fix stack overflow in vdiff when hashing large files. diff -uNr a/vtools/src/keccak_c.adb b/vtools/src/keccak_c.adb --- a/vtools/src/keccak_c.adb 8b4ed2ecae1c6fee1cc25f280351f57e4329d048617754f580ccc2df61734ede8d64d26dff20f29810a345b3e376ed6455f78e792eb02af14d1e5c6c757771fd +++ b/vtools/src/keccak_c.adb 130484edcb794a78db04eeb6293a21ef5ea70ac04c55a7641e67fac4879935fb1a51624081d583ae47bc30948610eaa6a3d6639ce53d0be53d7f315406d22e9a @@ -18,20 +18,30 @@ procedure C_Hash(Ctx: in C_Context_Access; Input: Char_Star; Len: Interfaces.C.size_t) is + Buffer_Size: constant Natural := 2048; + Byte_Size: constant Natural := 8; + N: Natural := 0; + I: Natural := 0; L: Natural := Natural(Len); - S: String(1..L); - B: Bitstream(1..S'Length*8); + Buf: String(1..Buffer_Size); + B: Bitstream(1..Buf'Length*Byte_Size); Ptr: Char_Star := Input; begin if Input = null then raise Strings.Dereference_Error; end if; - for Chr of S loop - Chr := Character(Ptr.all); - Char_Ptrs.Increment(Ptr); + while L > I loop + N := 0; + for Chr of Buf loop + exit when L <= I; + Chr := Character(Ptr.all); + Char_Ptrs.Increment(Ptr); + N := N + 1; + I := I + 1; + end loop; + ToBitstream(Buf(1..N), B(1..N*Byte_Size)); + KeccakHash(Ctx.all, B(1..N*Byte_Size)); end loop; - ToBitstream(S, B); - KeccakHash(Ctx.all, B); end C_Hash; procedure C_End(Ctx: C_Context_Access;