View Issue Details

IDProjectCategoryView StatusLast Update
0003344JEDI VCL00 JVCL Componentspublic2005-12-19 17:16
ReporterThomasAssigned ToAHUser 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.00 
Target VersionFixed in Version3.20 
Summary0003344: TJvCustomCipher EncodeString / DecodeString broken (but easy fix)
DescriptionWith

"
function TJvCustomCipher.EncodeString(const Key, Value: string): string;
var
  Tmp: PChar;
begin
  GetMem(Tmp, Length(Value) + 1);
  try
    StrPCopy(Tmp, Value);
    Encode(Key, Tmp, Length(Value));
    Result := Tmp;
  finally
    FreeMem(Tmp);
  end;
end;
"

The problem is the line "Result := Tmp;"
since that can potentially cut a lof of the string.
(if *Tmp* contains a #0 the whole stirng is not copied
- at least I experienced this running it on a 20 kb string.)
Additional InformationI propose solution:
"
        SetLength(Result, Length(Value));
        FillChar(Result[1], Length(Value), 0);
        Move(Tmp^, Result[1], Length(Value));
"


The same fix for *TJvCustomCipher.DecodeString(const Key, Value: string)*.


best regards
Thomas Schulz
TagsNo tags attached.

Activities

AHUser

2005-12-19 17:16

developer   ~0008227

Fixed in CVS.

I used SetString(Result, Tmp, Length(Value)); This is faster then filling the string with #0 and then overwriting those #0 with the actual data.

Issue History

Date Modified Username Field Change
2005-12-06 15:51 Thomas New Issue
2005-12-19 17:16 AHUser Status new => resolved
2005-12-19 17:16 AHUser Resolution open => fixed
2005-12-19 17:16 AHUser Assigned To => AHUser
2005-12-19 17:16 AHUser Note Added: 0008227