Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003344 [JEDI VCL] 00 JVCL Components minor always 2005-12-06 15:51 2005-12-19 17:16
Reporter Thomas View Status public  
Assigned To AHUser
Priority normal Resolution fixed  
Status resolved   Product Version 3.00
Summary 0003344: TJvCustomCipher EncodeString / DecodeString broken (but easy fix)
Description With

"
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 Information I 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
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0008227)
AHUser (developer)
2005-12-19 17:16

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


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker