#1 2013-12-23 13:34:33

pult
Member
From: Ukraine, Kyiv
Registered: 2013-11-06
Posts: 18

SynCommons.pas StringToGUID UNICODE - buffer not zero ended

fixing:

function StringToGUID(const text: string): TGUID;
{$ifdef UNICODE}
var tmp: array[0..{+}36{+.}] of byte;// ******** +1 ***********
    i: integer;
{$endif}
begin
  if (length(text)=38) and (text[1]='{') and (text[38]='}') then begin
    {$ifdef UNICODE}
    for i := 0 to 35 do
      tmp[i] := PWordArray(text)[i+1];
    {+}tmp[36] := 0;{+.} // ******** +2 ***********
    if TextToGUID(@tmp,@result)<>nil then
    {$else}
    if TextToGUID(@text[2],@result)<>nil then
    {$endif}
      exit; // conversion OK
  end;
  fillchar(result,sizeof(result),0);
end;

Offline

#2 2013-12-29 14:25:22

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: SynCommons.pas StringToGUID UNICODE - buffer not zero ended

The function TextToGUID() does not expect any zero ended buffer.

IMHO there is no problem in the current code.

Offline

Board footer

Powered by FluxBB