You are not logged in.
Pages: 1
Delphi 12.2
mORMot 2, Commit 2.3.11508
Shouldn't we check whether the content fits in the buffer before using the MoveFast function?
procedure TJsonWriter.AddFmt(Format: PUtf8Char; Values: PVarRec; ValuesCount: integer;
Escape: TTextWriterKind; WriteObjectOptions: TTextWriterWriteObjectOptions);
var
start: PUtf8Char;
Len: PtrInt;
begin
...
Len := Format - start;
if Len <> 0 then
begin
if BEnd - B <= Len then // note: PtrInt(BEnd - B) could be < 0
FlushToStream;
MoveFast(start^, B[1], Len);
With best regards
Thomas
Offline
The Format string is indeed expected to be smaller than the internal buffer size, which is 256 bytes as absolute minimum.
Some Fmt pointer in user code could indeed be bigger than this value.
I have seen people not using a constant, but pointer(anotherString) with a huge pre-calculated value.
Can you create an issue?
Edit:
https://github.com/synopse/mORMot2/issues/390 should be fixed now.
Offline
Pages: 1