View Issue Details

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

function TJvCustomCipher.EncodeString(const Key, Value: string): string;
  Tmp: PChar;
  GetMem(Tmp, Length(Value) + 1);
    StrPCopy(Tmp, Value);
    Encode(Key, Tmp, Length(Value));
    Result := Tmp;

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.



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